Skip to main content

Module cron

Module cron 

Source
Expand description

A cron expression parser and next-run calculator, written from scratch.

Five fields, in the order every crontab has used since 1975:

┌───────────── minute        0-59
│ ┌─────────── hour          0-23
│ │ ┌───────── day of month  1-31
│ │ │ ┌─────── month         1-12
│ │ │ │ ┌───── day of week   0-7  (0 and 7 are both Sunday)
* * * * *

Each field accepts *, a number, a list (1,15), a range (1-5), a step over the whole field (*/5) or over a range (0-30/10), and Vixie cron’s 5/10, which means “from 5 to the end of the field, every 10”.

Anything else is an error rather than a silent default. A schedule that quietly runs at the wrong time is worse than one that refuses to start.

Structs§

Cron
A parsed cron expression.

Enums§

Weekday
A day of the week, so weekly_on reads as English rather than as a number the caller has to remember the base of.