Documentation
¶
Overview ¶
Package timeutil provides some general purpose functionalities around the time package.
Index ¶
Constants ¶
View Source
const (
ISO8601 = "2006-01-02T15:04:05.000Z"
)
Variables ¶
View Source
var (
ErrInvalidDurationFormat = errors.New("invalid duration format")
)
Functions ¶
func NowAddPtr ¶
NowAddPtr adds t to now and returns the resulting time as *time.Time. If d is <= 0, nil is returned.
func ParseDuration ¶
ParseDuration tries to parse a duration from the passed string s. The format is composed of an integer number in combination with a time unit suffix. Following suffixes are supported:
- w (weeks)
- d (days)
- h (hours)
- m (minutes)
- s (seconds)
- s (seconds)
- ms (milliseconds)
- us / µs (microseconds)
- ns (nanoseconds)
Also spaces and tab spaces are supported between the elements of the duration string. A valid example would be following duration string:
"3w1d 4h12m3s40ms"
Also, substractions inside the duration strings are possible. The following example results in a furation of 23 hours.
"1d -1h"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.