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 {
// contains filtered or unexported fields
}
Schedule is a parsed cron expression.
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.