dates

package
v1.9.1-teampagebase.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 4 Imported by: 0

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

View Source
const ErrorYear string = "0000"
View Source
const Format string = time.RFC3339

2006-01-02T15:04:05Z07:00

View Source
const FormatY string = "2006"
View Source
const FormatYM string = "2006-01"
View Source
const FormatYMD string = "2006-01-02"
View Source
const FormatYMDHMS string = "2006-01-02T15:04:05"

Variables

View Source
var ErrorTime time.Time = time.Date(0, 0, 0, 0, 0, 0, 0, time.UTC)

Functions

func BillingDates added in v1.0.0

func BillingDates(when time.Time, billingDay int, months int) (s time.Time, e time.Time)

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 BillingEndDate(when time.Time, billingDay int) (m time.Time)

func FileCreationTime

func FileCreationTime(filepath string) (c time.Time, err error)

func GetFormat

func GetFormat(value string) string

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 IntervalFormat(i Interval) (f string)

func IsDate added in v1.0.0

func IsDate(str string) (valid bool)

func MaxTime

func MaxTime(times []time.Time) time.Time

MaxTime finds the max time in slice of times

func MustTime

func MustTime(t time.Time, e error) time.Time

func Range

func Range(start time.Time, end time.Time, interval Interval) []time.Time

Range provides a slice of times between the 2 dates with a variable interval allowing it to iterate by either day or month

func RangeEnd added in v1.4.0

func RangeEnd(end time.Time, interval Interval) (re time.Time)

func ResetDay

func ResetDay(d time.Time) time.Time

ResetDay resets time of the day to zeros

func ResetMonth

func ResetMonth(d time.Time) time.Time

ResetMonth resets the day of the month to the 1st and zeros the time

func StartEnd added in v1.6.0

func StartEnd(when time.Time, months int) (s time.Time, e time.Time)

func Strings added in v1.0.0

func Strings(dates []time.Time, format string) (strs []string)

Strings converts series of times into string versions using the date format passed

func Time

func Time(s string) time.Time

func ToTime

func ToTime(s string) (t time.Time, err error)

func YearToBillingDate added in v1.0.0

func YearToBillingDate(when time.Time, billingDay int) (s time.Time, e time.Time)

Types

type Interval

type Interval string
const (
	DAY   Interval = "DAY"
	MONTH Interval = "MONTH"
)

Jump to

Keyboard shortcuts

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