Documentation
¶
Overview ¶
Package cron parses standard five-field cron expressions and computes their next run times.
An expression has five fields separated by spaces: minute (0-59), hour (0-23), day of month (1-31), month (1-12 or JAN-DEC), and day of week (0-7 or SUN-SAT, where both 0 and 7 mean Sunday). Each field is "*", a value, a range "a-b", or a list of those separated by commas, and any of them may carry a step "/n". When both day fields are restricted, a day matches if either matches, as in classic cron. The macros @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly are also accepted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Schedule ¶
type Schedule struct {
// Minute, Hour, Dom, Month, and Dow are the values that each field
// matches, as sets of bits: bit v is set if the field matches v. Dow
// counts the days of the week from Sunday, 0, to Saturday, 6.
Minute, Hour, Dom, Month, Dow uint64
// EitherDay says how the two day fields combine. If it is true, a day
// matches when Dom or Dow matches it: that is so when neither field is
// "*". If it is false, a day matches when both match it.
EitherDay bool
}
Schedule is a parsed cron expression, as Parse returns it. Its fields say what the expression matches, for the dashboard, which puts it into words.
func (*Schedule) Next ¶
Next returns the first time after t that the schedule matches, in t's location. It fails if the schedule never matches, such as on February 31.
The schedule is matched against the wall clock, and each wall-clock time that it matches runs once, whatever the clock does. A time that the clock skips, when clocks go forward, runs as far after the jump as it is into the gap, among the times that the clock shows then. A time that the clock shows twice, when clocks go back, runs the first time only. Unlike classic cron, this holds for wildcard schedules too: "*/15 * * * *" makes no run in the repeated hour's second pass.