timeutil

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2022 License: MPL-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

func GetMostRecentContiguousMonths

func GetMostRecentContiguousMonths(startTimes []time.Time) []time.Time

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 InRange

func InRange(t, start, end time.Time) bool

func IsCurrentMonth

func IsCurrentMonth(t, compare time.Time) bool

IsCurrentMonth checks if :t: is in the current month, as defined by :compare: generally, pass in time.Now().UTC() as :compare:

func IsMonthStart

func IsMonthStart(t time.Time) bool

IsMonthStart checks if :t: is the start of the month

func IsPreviousMonth

func IsPreviousMonth(t, toCompare time.Time) bool

IsPreviousMonth checks if :t: is in the month directly before :toCompare:

func MonthsPreviousTo

func MonthsPreviousTo(months int, now time.Time) time.Time

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

func ParseTimeFromPath(path string) (time.Time, error)

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

func SkipAtEndOfMonth(t *testing.T)

Skip this test if too close to the end of a month!

func StartOfMonth

func StartOfMonth(t time.Time) time.Time

func StartOfNextMonth

func StartOfNextMonth(t time.Time) time.Time

func StartOfPreviousMonth

func StartOfPreviousMonth(t time.Time) time.Time

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL