Documentation
¶
Index ¶
- func AddWeeksToTime(dt time.Time, weeks int) time.Time
- func DaysRange(start time.Time, end time.Time) []int
- func EqualWithDrift(t1 time.Time, t2 time.Time, drift time.Duration) bool
- func FirstDayOfLastISOWeek(now func() time.Time) time.Time
- func FirstDayOfLastMonth(now func() time.Time) time.Time
- func FirstDayOfLastYear(now func() time.Time) time.Time
- func FirstDayOfNextISOWeek(now func() time.Time) time.Time
- func FirstDayOfNextMonth(now func() time.Time) time.Time
- func FirstDayOfNextYear(now func() time.Time) time.Time
- func FirstDayOfThisISOWeek(now func() time.Time) time.Time
- func FirstDayOfThisMonth(now func() time.Time) time.Time
- func FirstDayOfThisYear(now func() time.Time) time.Time
- func GetDatesByWeeklyBasedRecurringSchedule(startDT time.Time, weekdays []int8, totalWeeks int, weekFrequency int) []time.Time
- func GetDatesForExactDayByMonthlyBasedRecurringSchedule(startDT time.Time, totalMonths int, onExactDay int) []time.Time
- func GetDatesForFirstWeekDayByMonthlyBasedRecurringSchedule(startDT time.Time, totalMonths int, onFirstWeekday int) []time.Time
- func GetDatesForLastWeekDayByMonthlyBasedRecurringSchedule(startDT time.Time, totalMonths int, onLastWeekday int) []time.Time
- func GetDatesForWeekdaysBetweenRange(start time.Time, end time.Time, weekdays []int8) []time.Time
- func GetDayOfWeekUsingTomohikoSakamotoAlgorithm(d uint64, m uint64, y uint64) uint64
- func GetFirstDateFromMonthAndYear(month int, year int, loc *time.Location) time.Time
- func GetFirstDateFromWeekAndYear(wk int, year int, loc *time.Location) time.Time
- func GetFutureDateByFiveMinuteIntervalPattern(dt time.Time) time.Time
- func GetFutureDateByFiveteenMinuteIntervalPattern(dt time.Time) time.Time
- func GetFutureDateByOneHourIntervalPattern(dt time.Time) time.Time
- func GetFutureDateByTenMinuteIntervalPattern(dt time.Time) time.Time
- func GetFutureDateByThirtyMinuteIntervalPattern(dt time.Time) time.Time
- func GetHourRange(dt time.Time) (time.Time, time.Time)
- func GetMonthAbbreviation(month time.Month) string
- func GetMonthAbbreviationByInt(month int) string
- func GetWeekNumberFromDate(dt time.Time) int
- func GetWeekNumberFromTotalDaysCount(daysCount uint64) uint64
- func HourRangeForNow(now func() time.Time) (time.Time, time.Time)
- func IsAfter6PM(t time.Time) bool
- func IsAfternoon(t time.Time) bool
- func IsEvening(t time.Time) bool
- func IsFirstDayOfYear(dt time.Time) bool
- func IsMorning(t time.Time) bool
- func IsNight(t time.Time) bool
- func IsTimeOnFirstWeekOfMonth(pickedDT time.Time) bool
- func IsTimeOnLastWeekOfMonth(pickedDT time.Time) bool
- func LastDayOfThisISOWeek(now func() time.Time) time.Time
- func Midnight(now func() time.Time) time.Time
- func MidnightTomorrow(now func() time.Time) time.Time
- func MidnightYesterday(now func() time.Time) time.Time
- func MonthRange(start time.Time, end time.Time) []int
- func Noon(now func() time.Time) time.Time
- func ParseBubbleTime(s string) (time.Time, error)
- func ParseHourMinuteSecondDurationString(s string) (time.Duration, error)
- func ParseISO8601String(s string) (time.Time, error)
- func ParseJavaScriptTime(i int64) time.Time
- func ParseJavaScriptTimeString(s string) (time.Time, error)
- func RandomDate(startDate time.Time, endDate time.Time) time.Time
- func RangeFromTimeStepper(start time.Time, end time.Time, yearStep int, monthStep int, dayStep int, ...) []time.Time
- func To1AM(t time.Time) time.Time
- func ToAmericanDateString(t time.Time) string
- func ToAmericanDateTimeString(t time.Time) string
- func ToISO8601String(t time.Time) string
- func ToJavaScriptTime(t time.Time) int64
- func WeeksRange(start time.Time, end time.Time) []int
- func YearsRange(start time.Time, end time.Time) []int
- type DateInterval
- type SegmentedDateInterval
- type TimeRange
- func DailyRangeForNow(now func() time.Time) *TimeRange
- func DailyRangeForTime(dt time.Time) *TimeRange
- func DailyRangesBetweenTimes(start time.Time, end time.Time) []*TimeRange
- func HourlyRangeForNow(now func() time.Time) *TimeRange
- func HourlyRangeForTime(dt time.Time) *TimeRange
- func HourlyRangesBetweenTimes(start time.Time, end time.Time) []*TimeRange
- func ISOWeeklyRangeForNow(now func() time.Time) *TimeRange
- func ISOWeeklyRangeForTime(dt time.Time) *TimeRange
- func ISOWeeklyRangesBetweenTimes(start time.Time, end time.Time) []*TimeRange
- func MonthlyRangeForNow(now func() time.Time) *TimeRange
- func MonthlyRangeForTime(dt time.Time) *TimeRange
- func MonthlyRangesBetweenTimes(start time.Time, end time.Time) []*TimeRange
- func YearlyRangeForNow(now func() time.Time) *TimeRange
- func YearlyRangeForTime(dt time.Time) *TimeRange
- func YearlyRangesBetweenTimes(start time.Time, end time.Time) []*TimeRange
- type TimeStepper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddWeeksToTime ¶
AddWeeksToTime returns new time with weeks added to it.
func DaysRange ¶
DaysRange returns an array of the day integer values between two dates. For example if one date is January 1st 2000 and the other is January 5th 2000, the output will be [1,2,3,4,5].
func EqualWithDrift ¶
EqualWithDrift function will compare two date/times but will allow duration margin of error (which we call drift) between the comparison. For example, if we have +/- 2 second margin of error (aka drift) and input 2022-12-20T08:36:38Z and 2022-12-20T08:36:39Z then the result should be equal.
func FirstDayOfLastISOWeek ¶
FirstDayOfLastISOWeek returns the previous week's monday date.
func FirstDayOfLastMonth ¶
FirstDayOfLastMonth returns the date (with 0:00 hour) of the first day from last month.
func FirstDayOfLastYear ¶
FirstDayOfLastYear returns first date (with 0:00 hour) from last calendar year.
func FirstDayOfNextISOWeek ¶
FirstDayOfNextISOWeek return date of the upcoming monday.
func FirstDayOfNextMonth ¶
FirstDayOfNextMonth returns next months first day (in 12 AM hours).
func FirstDayOfNextYear ¶
FirstDayOfNextYear returns date (12AM) of the first date of next calendar year.
func FirstDayOfThisISOWeek ¶
FirstDayOfThisISOWeek return monday's date of this week. Please note monday is considered the first day of the week according to ISO 8601 and not sunday (which is what is used in Canada and USA).
func FirstDayOfThisMonth ¶
FirstDayOfThisMonth returns the first date (with 0:00 hour) from this month.
func FirstDayOfThisYear ¶
FirstDayOfThisYear returns the date (with 0:00 hour) from the first date of this calendar year.
func GetDatesByWeeklyBasedRecurringSchedule ¶
func GetDatesByWeeklyBasedRecurringSchedule(startDT time.Time, weekdays []int8, totalWeeks int, weekFrequency int) []time.Time
GetDatesByWeeklyBasedRecurringSchedule Generates a list of datetimes based on a weekly recuring schedule. Please note that dates start in first week and then week frequency is applied to restrict some weeks.
func GetDatesForExactDayByMonthlyBasedRecurringSchedule ¶
func GetDatesForExactDayByMonthlyBasedRecurringSchedule(startDT time.Time, totalMonths int, onExactDay int) []time.Time
GetDatesForExactDayByMonthlyBasedRecurringSchedule Generates a list of datetimes based on a monthly recuring schedule for the specific day number.
func GetDatesForFirstWeekDayByMonthlyBasedRecurringSchedule ¶
func GetDatesForFirstWeekDayByMonthlyBasedRecurringSchedule(startDT time.Time, totalMonths int, onFirstWeekday int) []time.Time
GetDatesForFirstWeekDayByMonthlyBasedRecurringSchedule Generates a list of datetimes based on a monthly recuring schedule which will find all the dates that fall on the weekday of the first week.
func GetDatesForLastWeekDayByMonthlyBasedRecurringSchedule ¶
func GetDatesForLastWeekDayByMonthlyBasedRecurringSchedule(startDT time.Time, totalMonths int, onLastWeekday int) []time.Time
GetDatesForLastWeekDayByMonthlyBasedRecurringSchedule Generates a list of datetimes based on a monthly recuring schedule which will find all the dates that fall on the weekday of the last week.
func GetDatesForWeekdaysBetweenRange ¶
GetDatesForWeekdaysBetweenRange returns all the date-times between two dates that fall for the specific picked weekdays.
func GetDayOfWeekUsingTomohikoSakamotoAlgorithm ¶
GetDayOfWeekUsingTomohikoSakamotoAlgorithm returns the day of the week where `0` = Sunday, `1` = Monday, etc.
func GetFirstDateFromMonthAndYear ¶
GetFirstDateFromMonthAndYear returns the first day in the month/year specified.
func GetFirstDateFromWeekAndYear ¶
GetFirstDateFromWeekAndYear returns the first date for the particular week in the year inputted.
func GetFutureDateByFiveMinuteIntervalPattern ¶
GetFutureDateByFiveMinuteIntervalPattern returns the future date that conforms to the 5 minute interval pattern. For example: Sunday Jan 9th - 1:00 AM --> Sunday Jan 9th - 1:00 AM Sunday Jan 9th - 1:01 AM --> Sunday Jan 9th - 1:05 AM Sunday Jan 9th - 1:28 AM --> Sunday Jan 9th - 1:30 AM Sunday Jan 9th - 1:59 AM --> Sunday Jan 9th - 2:00 AM Sunday Jan 9th - 11:59 PM --> Sunday Jan 10th - 12:00 AM
func GetFutureDateByFiveteenMinuteIntervalPattern ¶
GetFutureDateByFiveteenMinuteIntervalPattern returns the future date that conforms to the 5 minute interval pattern. For example: Sunday Jan 9th - 1:00 AM --> Sunday Jan 9th - 1:00 AM Sunday Jan 9th - 1:01 AM --> Sunday Jan 9th - 1:15 AM Sunday Jan 9th - 1:28 AM --> Sunday Jan 9th - 1:30 AM Sunday Jan 9th - 1:59 AM --> Sunday Jan 9th - 2:00 AM Sunday Jan 9th - 11:59 PM --> Sunday Jan 10th - 12:00 AM
func GetFutureDateByOneHourIntervalPattern ¶
GetFutureDateByOneHourIntervalPattern returns the future date that conforms to the 5 minute interval pattern. For example: Sunday Jan 9th - 1:00 AM --> Sunday Jan 9th - 1:00 AM Sunday Jan 9th - 1:01 AM --> Sunday Jan 9th - 1:05 AM Sunday Jan 9th - 1:28 AM --> Sunday Jan 9th - 1:30 AM Sunday Jan 9th - 1:59 AM --> Sunday Jan 9th - 2:00 AM Sunday Jan 9th - 11:59 PM --> Sunday Jan 10th - 12:00 AM
func GetFutureDateByTenMinuteIntervalPattern ¶
GetFutureDateByTenMinuteIntervalPattern returns the future date that conforms to the 5 minute interval pattern. For example: Sunday Jan 9th - 1:00 AM --> Sunday Jan 9th - 1:00 AM Sunday Jan 9th - 1:01 AM --> Sunday Jan 9th - 1:10 AM Sunday Jan 9th - 1:28 AM --> Sunday Jan 9th - 1:30 AM Sunday Jan 9th - 1:59 AM --> Sunday Jan 9th - 2:00 AM Sunday Jan 9th - 11:59 PM --> Sunday Jan 10th - 12:00 AM
func GetFutureDateByThirtyMinuteIntervalPattern ¶
GetFutureDateByThirtyMinuteIntervalPattern returns the future date that conforms to the 5 minute interval pattern. For example: Sunday Jan 9th - 1:00 AM --> Sunday Jan 9th - 1:00 AM Sunday Jan 9th - 1:01 AM --> Sunday Jan 9th - 1:30 AM Sunday Jan 9th - 1:28 AM --> Sunday Jan 9th - 1:30 AM Sunday Jan 9th - 1:59 AM --> Sunday Jan 9th - 2:00 AM Sunday Jan 9th - 11:59 PM --> Sunday Jan 10th - 12:00 AM
func GetHourRange ¶
GetHourRange function will take a date value and return two date times: (1) The first date time will take the date and discard the minutes, so for example if you give 12:30 PM then it will return 12:00 PM. (2) The second date time will disacrd the minutes and increase by 1 hour, for example if you give 12:30 PM then it will return 1:00 PM. Therefore the purpose of this function is to provide an hourly range for the inputted parameter. For example if I say 12:300 PM then this function will return 12:00 PM & 1:00 AM.
Developers Note: This would be useful to you if are building analytics engine which must group certain miunute based datapoints / timeseries into hours.
Here are some more examples to help you visualize: Monday Dec 18th - 9:30 AM --> (1) Monday Dec 18th - 9:00 AM and (2) Monday Dec 18th - 10:00 AM Monday Dec 18th - 5:10 PM --> (1) Monday Dec 18th - 5:00 PM and (2) Monday Dec 18th - 7:00 PM Monday Dec 18th - 10:55 PM --> (1) Monday Dec 18th - 10:00 PM and (2) Monday Dec 18th - 11:00 PM
func GetMonthAbbreviation ¶
GetMonthAbbreviation returns the 3-character abbreviation for the provided month.
func GetMonthAbbreviationByInt ¶
GetMonthAbbreviationByInt returns the 3-character abbreviation for the provided month number.
func GetWeekNumberFromDate ¶
GetWeekNumberFromDate will return the week number for the inputted date.
func GetWeekNumberFromTotalDaysCount ¶
GetWeekNumberFromTotalDaysCount returns the week number from total days count. For example daysCount=8, returns=2 or daysCount=365, returned=52.
func HourRangeForNow ¶
HourRangeForNow works just like the `GetHourRange` function however it works for the current date/time.
func IsAfternoon ¶
IsAfternoon returns true if time is between 12PM to 4:59PM or (24 to 16:59) in 24 hour format
func IsEvening ¶
IsEvening returns true if time is between 5PM to 7:59PM or (17 to 19:59) in 24 hour format
func IsFirstDayOfYear ¶
IsFirstDayOfYear returns true or false depending on whether the date inputted falls on the very first day of the year.
func IsMorning ¶
IsMorning returns true if time is between 12 AM to 11:59 AM or (12 to 11:59) in 24 hour format
func IsNight ¶
IsNight returns true if time is between 8PM to 11:59 PM or (20 to 22:59) in 24 hour format
func IsTimeOnLastWeekOfMonth ¶
func LastDayOfThisISOWeek ¶
LastDayOfThisISOWeek return sunday's date of this week. Please note sunday is considered the last day of the week according to ISO 8601.
func MidnightTomorrow ¶
MidnightTomorrow will return tomorrows date at 12 o’clock (or 0:00) during the night.
func MidnightYesterday ¶
MidnightYesterday return 12 AM date of yesterday.
func MonthRange ¶
MonthRange returns an array of the month integer values between two dates. For example if one date is January 2000 and the other is March 2000, the output will be [1,2,3].
func ParseBubbleTime ¶
ParseBubbleTime will convert the date/time string (ex: "Nov 11, 2011 11:00 am") used "https://bubble.io" into Golang `time`. You will find need of this function if the Bubble.io app you built will be making an API call to your Golang backend server.
func ParseHourMinuteSecondDurationString ¶
ParseHourMinuteSecondDurationString will convert a HH:MM:SS string (example: "08:30:00") into duration.
func ParseISO8601String ¶
ParseISO8601String converts ISO8601 compliant date-time string into a Golang `time.Time` object.
func ParseJavaScriptTime ¶
ParseJavaScriptTime will convert the number of milliseconds since the Unix Epoch parameter into Golang `time` format. As a result, the output of the JavaScript `getTime()` function can be used as the parameter in this function.
func ParseJavaScriptTimeString ¶
ParseJavaScriptTimeString will convert the string of milliseconds integers since the Unix Epoch parameter into Golang `time` format. As a result, the output of the JavaScript `getTime()` function can be used as the parameter in this function.
func RandomDate ¶
RandomDate Generates a random date between two given dates.
func RangeFromTimeStepper ¶
func RangeFromTimeStepper(start time.Time, end time.Time, yearStep int, monthStep int, dayStep int, hourStep int, minuteStep int, secondStep int) []time.Time
RangeFromTimeStepper function returns an array of datetime values from the starting date up to and including the finish date according to the step pattern specified in the parameter.
func To1AM ¶
To1AM will take entered date/time and return same date but time starts at 1 AM (01:00:00).
func ToAmericanDateString ¶
ToAmericanDateString will convert the Golang Date/Time format into the American style of notation string as mentioned via https://en.wikipedia.org/wiki/Date_and_time_notation_in_the_United_States.
func ToAmericanDateTimeString ¶
ToAmericanDateTimeString will convert the Golang Date/Time format into the American style of notation string as mentioned via https://en.wikipedia.org/wiki/Date_and_time_notation_in_the_United_States.
func ToISO8601String ¶
ToISO8601String will convert the Golang `Date` format into an ISO 8601 formatted date/time string.
func ToJavaScriptTime ¶
ToJavaScriptTime will return a Unix Epoch time value that your JavaScript code can read into JavaScript `Date` format. Example JavaScript code snippet of using the results of this function: `var date = new Date(UNIX_Timestamp * 1000);` as an example.
func WeeksRange ¶
WeeksRange returns an array of the week integer values between two dates. For example if one date is January 1st 2022 and the other is January 10th 2022, the output will be [52,1,2].
Types ¶
type DateInterval ¶
DateInterval struct represents start and end dates.
func RandomDateIntervals ¶
RandomDateIntervals Generates a list of date intervals between two dates.
type SegmentedDateInterval ¶
type SegmentedDateInterval struct { ID int64 Interval *DateInterval }
SegmentedDateInterval struct represents an date interval with a segment ID to track what segment the date interval belongs to.
func RandomSegmentedDateIntervals ¶
func RandomSegmentedDateIntervals(startDate time.Time, endDate time.Time, maxSeconds int64, totalSegments int64) []*SegmentedDateInterval
RandomSegmentedDateIntervals Generates a segmented list of date intervals between two dates.
type TimeRange ¶
func DailyRangeForNow ¶
DailyRangeForNow (TODO: Write detailed description)
func DailyRangeForTime ¶
DailyRangeForTime (TODO: Write detailed description)
func DailyRangesBetweenTimes ¶
DailyRangesBetweenTimes (TODO: Write detailed description)
func HourlyRangeForNow ¶
HourlyRangeForNow (TODO: Write detailed description)
func HourlyRangeForTime ¶
HourlyRangeForTime function will take a date value and return two date times: (1) The first date time will take the date and discard the minutes, so for example if you give 12:30 PM then it will return 12:00 PM. (2) The second date time will disacrd the minutes and increase by 1 hour, for example if you give 12:30 PM then it will return 1:00 PM. Therefore the purpose of this function is to provide an hourly range for the inputted parameter. For example if I say 12:300 PM then this function will return 12:00 PM & 1:00 AM.
Developers Note: This would be useful to you if are building analytics engine which must group certain miunute based datapoints / timeseries into hours.
Here are some more examples to help you visualize: Monday Dec 18th - 9:30 AM --> (1) Monday Dec 18th - 9:00 AM and (2) Monday Dec 18th - 10:00 AM Monday Dec 18th - 5:10 PM --> (1) Monday Dec 18th - 5:00 PM and (2) Monday Dec 18th - 7:00 PM Monday Dec 18th - 10:55 PM --> (1) Monday Dec 18th - 10:00 PM and (2) Monday Dec 18th - 11:00 PM
func HourlyRangesBetweenTimes ¶
HourlyRangesBetweenTimes (TODO: Write detailed description)
func ISOWeeklyRangeForNow ¶
ISOWeeklyRangeForNow (TODO: Write detailed description)
func ISOWeeklyRangeForTime ¶
ISOWeeklyRangeForTime (TODO: Write detailed description)
func ISOWeeklyRangesBetweenTimes ¶
ISOWeeklyRangesBetweenTimes (TODO: Write detailed description)
func MonthlyRangeForNow ¶
MonthlyRangeForNow (TODO: Write detailed description)
func MonthlyRangeForTime ¶
MonthlyRangeForTime (TODO: Write detailed description)
func MonthlyRangesBetweenTimes ¶
MonthlyRangesBetweenTimes (TODO: Write detailed description)
func YearlyRangeForNow ¶
func YearlyRangeForTime ¶
YearlyRangeForTime (TODO: Write detailed description)
type TimeStepper ¶
type TimeStepper struct {
// contains filtered or unexported fields
}
TimeStepper is a structure to hold keep track of the position we are in the datetime range which we are stepping through.
func NewTimeStepper ¶
func NewTimeStepper(start time.Time, end time.Time, yearStep int, monthStep int, dayStep int, hourStep int, minuteStep int, secondStep int) *TimeStepper
NewTimeStepper is a constructor of the `TimeStepper` struct.
func (*TimeStepper) Done ¶
func (ts *TimeStepper) Done() bool
Done checks to see if the stepper has stepped over the end datetime and will return true or false according.
func (*TimeStepper) Get ¶
func (ts *TimeStepper) Get() time.Time
Get will return the value that that the stepper is currently on.
func (*TimeStepper) Next ¶
func (ts *TimeStepper) Next() bool
Next makes one time step over and returns true or false depending if the stepper has stepped over the end datetime.