Documentation ¶
Index ¶
- func AddDays(t time.Time, n int) time.Time
- func AddHours(t time.Time, n int) time.Time
- func AddMonths(t time.Time, n int) time.Time
- func DiffEqual(d time.Duration, t0 time.Time, ts ...time.Time) bool
- func DurationAbs(d time.Duration) time.Duration
- func Pointer(v time.Time) *time.Time
- func TimeOrDefault(v *time.Time, defaultVal time.Time) *time.Time
- func TruncEqual(d time.Duration, t0 time.Time, ts ...time.Time) bool
- type MockTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationAbs ¶
DurationAbs returns the absolute (positive) value of a time.Duration.
func Pointer ¶
Pointer returns a pointer to the given time.Time. NOTE: this method is deprecated. Use helpy.Pointer instead.
func TimeOrDefault ¶
TimeOrDefault returns time.Time if it is not nil, and a pointer to defaultVal otherwise. NOTE: this method is deprecated. Use helpy.DerefOrValue instead.
Types ¶
type MockTime ¶ added in v0.1.13
MockTime helps mock time for functions that take a func() time.Time argument to retrieve the time, instead of using the global time.Now(). This is especially useful when testing functions that depend on time.
func NewMockTime ¶ added in v0.1.13
NewMockTime returns a MockTime with the given time.Time instance. If now is nil, it will default to time.Now().