mirror of
https://github.com/foomo/keel.git
synced 2025-10-16 12:35:34 +00:00
37 lines
657 B
Go
37 lines
657 B
Go
package keeltime
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
Now = time.Now
|
|
NowStaticNSec = int64(1609498800e9) // 2021-01-01 12:00:00
|
|
NowIncrementalNSec = NowStaticNSec
|
|
)
|
|
|
|
// Static sets now to a static time provider
|
|
func Static() {
|
|
Now = static
|
|
}
|
|
|
|
// Incremental sets now to a incremental time provider
|
|
func Incremental() {
|
|
Now = incremental
|
|
}
|
|
|
|
func static() time.Time {
|
|
return time.Unix(0, NowStaticNSec)
|
|
}
|
|
|
|
func incremental() time.Time {
|
|
t := time.Unix(0, NowIncrementalNSec)
|
|
NowIncrementalNSec++
|
|
return t
|
|
}
|
|
|
|
// ResetIncremental sets the incremental time to the static default
|
|
func ResetIncremental() {
|
|
NowIncrementalNSec = NowStaticNSec
|
|
}
|