schedule

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ActiveTriggerCount = 4

ActiveTriggerCount is the number of cron triggers actually scheduled. The 5th slot is calculated but not deployed (overnight gap).

Variables

This section is empty.

Functions

func Calculate

func Calculate(startTime string) []string

Calculate returns 5 time slots at 5-hour intervals starting from startTime. startTime must be in "HH:MM" 24-hour format.

func DetectTimezone

func DetectTimezone() string

func GetNextTrigger

func GetNextTrigger(schedule []string, timezone string) (nextTime time.Time, label string)

GetNextTrigger returns the next upcoming trigger as a time.Time and a human-readable label. Uses only the first ActiveTriggerCount slots.

func GetResetTime

func GetResetTime(triggerTime string) string

GetResetTime returns the time 5 hours after triggerTime. triggerTime must be in "HH:MM" 24-hour format.

func ToCron

func ToCron(times []string, timezone string) string

ToCron converts local times + timezone to a UTC cron expression. Only the first ActiveTriggerCount slots are included. Returns format: "M H1,H2,H3,H4 * * *"

Known limitation: uses a single UTC offset snapshot from time.Now(). For DST-observing timezones, the baked-in offset becomes stale after a DST transition (±1 hour). Cloudflare Workers cron API does not support CRON_TZ, so there is no server-side fix. Users should run `tokfresh update` after a DST change, or choose a non-DST timezone (e.g., UTC).

Types

This section is empty.

Jump to

Keyboard shortcuts

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