schedule

package
v1.1.41 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDailyScheduleMatch

func CheckDailyScheduleMatch(schedule time.Time, since time.Time, now time.Time) bool

CheckDailyScheduleMatch determines if the `schedule` time's daily repetition happened between `since` and `now`. We assume that `since` is before `now`.

An important edge case here is if midnight falls in between `since` and `now`. We want to convert `schedule` to the correct day, but there's now two possible candidates.

We handle this case by always initially converting `schedule` to `now`'s day. If `schedule` is then ahead of `now`, we convert it to `since`'s day instead and then try again. Suppose `since` of 23:50 and `now` of 00:10. If `since` is 00:05, we correct identify it on the first pass, since it being on `now`'s day puts it between the two times. If since is 23:55, we correctly identify it on the second pass.

This edge case handling is correct in all cases because this function is concerned just with daily repetitions. We could brute-force check all possible dates here and this function wouldn't be incorrect.

func IsWeekendDay

func IsWeekendDay(date time.Time) bool

IsWeekendDay returns if the date occurred on a weekend day. The same time will be different days in different timezones so be careful if you're passing UTC timestamps to this function--see the tests for an example.

Types

This section is empty.

Jump to

Keyboard shortcuts

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