Documentation ¶
Overview ¶
Package timeutil exports functions and types related to time and date.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
A Clock is an object that can tell you the current time.
This interface allows decoupling code that uses time from the code that creates a point in time. You can use this to your advantage by injecting Clocks into interfaces rather than having implementations call time.Now() directly.
Use RealClock() in production. Use SimulatedClock() in test.
func NewRealClock ¶
func NewRealClock() Clock
type SimulatedClock ¶
type SimulatedClock struct {
// contains filtered or unexported fields
}
A SimulatedClock is a concrete Clock implementation that doesn't "tick" on its own. Time is advanced by explicit call to the AdvanceTime() or SetTime() functions. This object is concurrency safe.
func NewSimulatedClock ¶
func NewSimulatedClock(t time.Time) *SimulatedClock
func (*SimulatedClock) AdvanceTime ¶
func (c *SimulatedClock) AdvanceTime(d time.Duration)
func (*SimulatedClock) Now ¶
func (c *SimulatedClock) Now() time.Time
func (*SimulatedClock) SetTime ¶
func (c *SimulatedClock) SetTime(t time.Time)
Click to show internal directories.
Click to hide internal directories.