init: 1.0.0
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package timex
|
||||
|
||||
import "time"
|
||||
|
||||
// Use the long enough past time as start time, in case timex.Now() - lastTime equals 0.
|
||||
var initTime = time.Now().AddDate(-1, -1, -1)
|
||||
|
||||
// Now returns a relative time duration since initTime, which is not important.
|
||||
// The caller only needs to care about the relative value.
|
||||
func Now() time.Duration {
|
||||
return time.Since(initTime)
|
||||
}
|
||||
|
||||
// Since returns a diff since given d.
|
||||
func Since(d time.Duration) time.Duration {
|
||||
return time.Since(initTime) - d
|
||||
}
|
||||
Reference in New Issue
Block a user