Documentation
¶
Overview ¶
Package ctxtime provides access to either the current time, or a time that has been cached in a context. It is intended to provide consistent time information in tests and other similar situation whilst being as unintrusive as possible.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTime ¶
ContextWithTime attaches the given time to a context. All subsequent calls to Now will return this time. If the given time is the zero time, then Now will return the system time.
It is expected that ContextWithTime is most useful for having consistent times in tests.
func Now ¶
Now determines the current time. If a non-zero time has been added to the given context using ContextWithTime then this time will be returned, otherwise the value of time.Now will be used.
func UTCMilliseconds ¶
UTCMilliseconds is a convenience funtion that returns the time returned by Now, but in the UTC time zone and rounded to the nearest millisecond.
Types ¶
This section is empty.