Documentation ¶
Overview ¶
Package dates groups a series of funcs converting between time.Time and string
Provides series of helpers for string to become time.Time and to parse / convert existing times.Time into common formats and structs
Index ¶
- Constants
- Variables
- func BillingDates(when time.Time, billingDay int, months int) (s time.Time, e time.Time)
- func BillingEndDate(when time.Time, billingDay int) (m time.Time)
- func FileCreationTime(filepath string) (c time.Time, err error)
- func GetFormat(value string) string
- func IntervalFormat(i Interval) (f string)
- func IsDate(str string) (valid bool)
- func MaxTime(times []time.Time) time.Time
- func MustTime(t time.Time, e error) time.Time
- func Range(start time.Time, end time.Time, interval Interval) []time.Time
- func RangeEnd(end time.Time, interval Interval) (re time.Time)
- func ResetDay(d time.Time) time.Time
- func ResetMonth(d time.Time) time.Time
- func StartEnd(when time.Time, months int) (s time.Time, e time.Time)
- func Strings(dates []time.Time, format string) (strs []string)
- func Time(s string) time.Time
- func ToTime(s string) (t time.Time, err error)
- func YearToBillingDate(when time.Time, billingDay int) (s time.Time, e time.Time)
- type Interval
Constants ¶
const ErrorYear string = "0000"
const Format string = time.RFC3339
2006-01-02T15:04:05Z07:00
const FormatY string = "2006"
const FormatYM string = "2006-01"
const FormatYMD string = "2006-01-02"
const FormatYMDHMS string = "2006-01-02T15:04:05"
Variables ¶
Functions ¶
func BillingDates ¶ added in v1.0.0
BillingDates returns the first day of start month and the last day of the billing month - the end date date is midnight the day after to be used in less than (<) queries
func BillingEndDate ¶ added in v1.0.0
func GetFormat ¶
GetFormat will return the format to use for the date string passed, using time.RFC3339 as base.
Passing 2024 would return 2006, passing 2024-12-01 would return 2006-01-02 and so on
func IntervalFormat ¶ added in v1.1.0
func Range ¶
Range provides a slice of times between the 2 dates with a variable interval allowing it to iterate by either day or month
func ResetMonth ¶
ResetMonth resets the day of the month to the 1st and zeros the time