Documentation ¶
Overview ¶
Utilities for messing with time.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationHMS ¶ added in v1.7.55
Extracts the hours, minutes, and seconds from the given duration.
func FormatTimer ¶ added in v1.7.55
Formats the given duration in a colon-separated timer format in the form [HH:]MM:SS.
Example (Complete) ¶
fmt.Print(FormatTimer(23*time.Hour + 4*time.Minute + 13*time.Second))
Output: 23:04:13
Example (OneHour) ¶
fmt.Print(FormatTimer(time.Hour))
Output: 1:00:00
Example (OneMinute) ¶
fmt.Print(FormatTimer(time.Minute))
Output: 1:00
Example (OneSecond) ¶
fmt.Print(FormatTimer(time.Second))
Output: 0:01
Example (OverOneMinute) ¶
fmt.Print(FormatTimer(119 * time.Second))
Output: 1:59
Example (UnderOneMinute) ¶
fmt.Print(FormatTimer(59 * time.Second))
Output: 0:59
Example (ZeroValue) ¶
fmt.Print(FormatTimer(0))
Output: 0:00
func FormatTimerf ¶ added in v1.7.55
Formats the given duration using the given format string. The string follows the same formatting rules as described in the fmt package, and will receive three integer arguments: hours, minutes, and seconds.
func ParseDuration ¶
Provides an API-compatible version of time.ParseDuration that accepts additional formats for parsing durations:
1y, 3year, 5years: Expands to (n*24*365) hours 1w, 3weeks, 5wks: Expands to (n*24*7) hours 1d, 1day, 5days: Expands to (n*24) hours
func ReferenceTime ¶ added in v1.8.41
Return the standard Golang reference time (2006-01-02T15:04:05.999999999Z07:00)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.