2020-06-26 12:16:13 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
const Day = time.Hour * 24
|
|
|
|
|
2021-08-29 13:26:05 +02:00
|
|
|
// TimeStamp returns the current timestamp in UTC rounded to seconds.
|
|
|
|
func TimeStamp() time.Time {
|
2020-06-26 12:16:13 +02:00
|
|
|
return time.Now().UTC().Round(time.Second)
|
|
|
|
}
|
|
|
|
|
2021-08-29 13:26:05 +02:00
|
|
|
// TimePointer returns a pointer to the current timestamp.
|
|
|
|
func TimePointer() *time.Time {
|
|
|
|
t := TimeStamp()
|
2021-08-23 16:22:01 +02:00
|
|
|
return &t
|
|
|
|
}
|
|
|
|
|
2020-06-26 12:16:13 +02:00
|
|
|
// Seconds converts an int to a duration in seconds.
|
|
|
|
func Seconds(s int) time.Duration {
|
|
|
|
return time.Duration(s) * time.Second
|
|
|
|
}
|
2021-01-27 15:17:45 +01:00
|
|
|
|
|
|
|
// Yesterday returns the time 24 hours ago.
|
|
|
|
func Yesterday() time.Time {
|
|
|
|
return time.Now().Add(-24 * time.Hour)
|
|
|
|
}
|