photoprism/internal/entity/time.go
2021-08-23 16:22:01 +02:00

26 lines
572 B
Go

package entity
import "time"
const Day = time.Hour * 24
// Timestamp returns the current time in UTC rounded to seconds.
func Timestamp() time.Time {
return time.Now().UTC().Round(time.Second)
}
// TimestampPointer returns a current timestamp pointer.
func TimestampPointer() *time.Time {
t := Timestamp()
return &t
}
// Seconds converts an int to a duration in seconds.
func Seconds(s int) time.Duration {
return time.Duration(s) * time.Second
}
// Yesterday returns the time 24 hours ago.
func Yesterday() time.Time {
return time.Now().Add(-24 * time.Hour)
}