Documentation ¶
Index ¶
- func EndOfMonth(t time.Time) time.Time
- func GetMostRecentContiguousMonths(startTimes []time.Time) []time.Time
- func InRange(t, start, end time.Time) bool
- func IsCurrentMonth(t, compare time.Time) bool
- func IsMonthStart(t time.Time) bool
- func IsPreviousMonth(t, toCompare time.Time) bool
- func MonthsPreviousTo(months int, now time.Time) time.Time
- func ParseTimeFromPath(path string) (time.Time, error)
- func SkipAtEndOfMonth(t *testing.T)
- func StartOfMonth(t time.Time) time.Time
- func StartOfNextMonth(t time.Time) time.Time
- func StartOfPreviousMonth(t time.Time) time.Time
- type Clock
- type DefaultClock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMostRecentContiguousMonths ¶
GetMostRecentContinuousMonths finds the start time of the most recent set of continguous months.
For example, if the most recent start time is Aug 15, then that range is just 1 month If the recent start times are Aug 1 and July 1 and June 15, then that range is three months and we return June 15.
note: return slice will be nil if :startTimes: is nil :startTimes: must be sorted in decreasing order (see unit test for examples)
func IsCurrentMonth ¶
IsCurrentMonth checks if :t: is in the current month, as defined by :compare: generally, pass in time.Now().UTC() as :compare:
func IsMonthStart ¶
IsMonthStart checks if :t: is the start of the month
func IsPreviousMonth ¶
IsPreviousMonth checks if :t: is in the month directly before :toCompare:
func MonthsPreviousTo ¶
Compute the N-month period before the given date. For example, if it is currently April 2020, then 12 months is April 2019 through March 2020.
func ParseTimeFromPath ¶
ParseTimeFromPath returns a UTC time from a path of the form '<timestamp>/', where <timestamp> is a Unix timestamp
func SkipAtEndOfMonth ¶ added in v1.7.0
Skip this test if too close to the end of a month!
Types ¶
type Clock ¶ added in v1.11.12
type Clock interface { Now() time.Time NewTicker(time.Duration) *time.Ticker NewTimer(time.Duration) *time.Timer }
This interface allows unit tests to substitute in a simulated Clock.
type DefaultClock ¶ added in v1.11.12
type DefaultClock struct{}
func (DefaultClock) NewTicker ¶ added in v1.11.12
func (_ DefaultClock) NewTicker(d time.Duration) *time.Ticker
func (DefaultClock) NewTimer ¶ added in v1.11.12
func (_ DefaultClock) NewTimer(d time.Duration) *time.Timer
func (DefaultClock) Now ¶ added in v1.11.12
func (_ DefaultClock) Now() time.Time