Documentation
¶
Index ¶
- func Ceil(x time.Time, d time.Duration) time.Time
- func CeilDuration(x, d time.Duration) time.Duration
- func Floor(x time.Time, d time.Duration) time.Time
- func FloorDuration(x, d time.Duration) time.Duration
- func Mod(action ModAction, x time.Time, d time.Duration) time.Time
- func ModDuration(action ModAction, x, d time.Duration) time.Duration
- func ParseDuration(s string, base time.Time) (dur int64, err error)
- func ParseTime(s string, base time.Time) (t time.Time, err error)
- func Round(x time.Time, d time.Duration) time.Time
- func RoundDuration(x, d time.Duration) time.Duration
- type ModAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mod ¶
Mod returns a new time based on t in timezone of the time t
time.{Round, Truncat} operates on UTC time
e.g. 01:01:31 in TZ -11:30 (12:31:31 in UTC)
timezone offset = -11:30
thus will have default behavior when dur is 1hr
time.Round(12:31:31): 13:00:00 UTC -> 01:30:00 in TZ -11:30 time.Truncat(12:31:31): 12:00:00 UTC -> 00:30:00 in TZ -11:30
what actually expected to local time is
floor: 01:00:00 round: 01:00:00 ceil: 02:00:00
func ModDuration ¶
ModDuration return a new duration of x that is multiple of d
func ParseDuration ¶
ParseDuration parses durations like
1000ns, 200us, 100ms, 1s, 2m, 3h, 4d, 5w, 6M, 6y 1d2h, 5w3d
following units are supported:
ns - nanoseconds us - microseconds ms - milliseconds s - seconds m - minutes h or hr - hours d - days w - weeks M or mt - months y or yr - years
only supports decimal numbers, other number format may cause silent error
months and years are normalized on the basis of the base time and MUST be integer values, other units are deterministic
parsed value is the duration in nanoseconds