Documentation ¶
Overview ¶
Package datetime implements a variety of date/time utilities that make it easier to build and test applications which use dates and times.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ITime ¶
ITime implements json.Marshaler interface, and is a replacement for time.Time which is to be used solely in structs which are intended to be passed to json.Marshal(). Ordinarily, Go by default uses the RFC3339 Nano format, which includes floating point second precision. Use this instead when you want to write integer-second UTC timestamps.
func (ITime) MarshalJSON ¶
MarshalJSON implements interface json.Marshaler
type NowTimeProvider ¶
NowTimeProvider implements interface TimeProvider to provide the real value of 'now' (which is always changing), or an artificially-set value (which does not change over time automatically).
func NewNowTimeProvider ¶
func NewNowTimeProvider() *NowTimeProvider
NewNowTimeProvider constructs a new NowTimeProvider initialised to return the current (changing) time
func (*NowTimeProvider) Now ¶
func (p *NowTimeProvider) Now() (t time.Time)
Now implements interface TimeProvider. If SetNow() has not been called, then successive calls to Now() will return the actual real (changing) time. If SetNow() has been called, then the value returned will always remain the same - that passed to SetNow().
func (*NowTimeProvider) SetNow ¶
func (p *NowTimeProvider) SetNow(t time.Time)
SetNow implements interface TimeProvider. If called, then all future calls to Now() will return the value passed.
type TimeProvider ¶
type TimeProvider interface { SetNow(t time.Time) Now() (t time.Time) Until(t time.Time) time.Duration Since(t time.Time) time.Duration }
TimeProvider is the interface that wraps methods which allow the setting and getting of 'now' which, for the purposes of testing, might have been set to an explicit value.