2020-09-22 11:49:58 +00:00
|
|
|
// Package timeutils is a wrapper around the go standard time library.
|
|
|
|
package timeutils
|
2019-08-09 14:05:08 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2020-09-22 05:47:01 +00:00
|
|
|
// Since returns the duration since t.
|
2019-08-09 14:05:08 +00:00
|
|
|
func Since(t time.Time) time.Duration {
|
2019-08-13 17:59:11 +00:00
|
|
|
return Now().Sub(t)
|
2019-08-09 14:05:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 05:47:01 +00:00
|
|
|
// Until returns the duration until t.
|
2019-08-09 14:05:08 +00:00
|
|
|
func Until(t time.Time) time.Duration {
|
2019-08-13 17:59:11 +00:00
|
|
|
return t.Sub(Now())
|
|
|
|
}
|
|
|
|
|
2020-09-22 05:47:01 +00:00
|
|
|
// Now returns the current local time.
|
2019-08-13 17:59:11 +00:00
|
|
|
func Now() time.Time {
|
2020-08-14 19:22:58 +00:00
|
|
|
return time.Now()
|
2019-08-09 14:05:08 +00:00
|
|
|
}
|