Documentation ¶
Overview ¶
Package times provides a set of utilities related to processing time.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultClock = &defaultClock{}
DefaultClock implements Clock by delegating to methods in package time.
Functions ¶
func ParseIso8601UTC ¶
ParseIso8601UTC parses a time in Iso8601 format and UTC timezone (yyyy-MM-ddTHH:mm:ss.fffZ).
func ParseIsoDashUTC ¶
ParseIsoDashUTC parses a time in IsoDash format and UTC timezone (yyyy-MM-ddTHH-mm-ss.fffZ).
func ToIso8601UTC ¶
ToIso8601UTC converts a time into a string in Iso8601 format in UTC timezone (yyyy-MM-ddTHH:mm:ss.fffZ).
Example ¶
fmt.Println(ToIso8601UTC(time.Date(2015, 6, 30, 0, 29, 4, 569000000, time.UTC)))
Output: 2015-06-30T00:29:04.569Z
Example (Locale) ¶
mst := time.FixedZone("MST", -7*3600) // seven hours west of UTC fmt.Println(ToIso8601UTC(time.Date(2015, 6, 3, 0, 9, 4, 569100000, mst)))
Output: 2015-06-03T07:09:04.569Z
Types ¶
type Clock ¶
type Clock interface { // Now returns the current time. Now() time.Time // After returns a channel that will receive after the given duration. After(time.Duration) chan struct{} }
Clock is an interface that can provide time related functionality.
type MockedClock ¶
MockedClock implements the Now method to return a predictable time and the After method to return a channel that ca be woken up on demand.
func NewMockedClock ¶
func NewMockedClock() *MockedClock
NewMockedClock creates a new instance of a mocked clock
func (*MockedClock) After ¶
func (c *MockedClock) After(d time.Duration) chan struct{}
After returns a channel that receives when we tell it to.