Documentation
¶
Overview ¶
Package cron parses 5-field cron expressions in an IANA time zone and computes their next slot under one daylight-saving rule, for every funcd consumer of a cron schedule (ADR-0211). It imports the standard library and api/fault only, and not time/tzdata: a program that needs zones without host files imports that itself.
Index ¶
Constants ¶
const Grammar = "a cron expression: 5 fields (minute hour day-of-month month day-of-week) of *, n, a-b, */s or " +
"a-b/s in comma lists, or @yearly, @annually, @monthly, @weekly, @daily, @midnight or @hourly"
Grammar describes the accepted expressions in words; every parse error quotes it.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Timetable ¶
type Timetable struct {
// contains filtered or unexported fields
}
Timetable is a parsed expression in a zone (Decision 1). Immutable and safe for concurrent use.
func Parse ¶
Parse parses expr in loc (nil ⇒ UTC): fault.Invalid naming expr, the failing field and Grammar, also when the expression matches no calendar date.
func (*Timetable) Next ¶
Next returns the earliest slot instant strictly after after (Decision 3). It never returns the zero Time for a Timetable from Parse.
A slot maps to the first instant whose local time is not earlier than the slot: the slot itself, its first occurrence in a fold, the end of the gap in a gap. That map never decreases with the slot, and a slot no later than after's local time maps to no later than after, so the answer is the first later slot whose instant is after after.