cron

Cron expressions for Ecko: parse the five classic fields, ask when a schedule next fires, and test whether a moment matches. Pure - no capabilities.

ecko get github.com/ecko-lang/cron
import cron

Pure computation: it declares no capabilities, so it cannot touch the network, the filesystem or the environment.

Version 0.30.0 - source - MIT.


parse(expr)

parse(expr) -> a schedule, or raises kind cron.

expr is five fields, or one of the @daily shortcuts. Whitespace between fields is any amount.

parse("*/15 9-17 * * mon-fri")

matches(schedule, ms)

matches(schedule, ms) -> whether the minute containing ms is one it fires in.

next(schedule, from_ms)

next(schedule, from_ms) -> the first firing time strictly after from_ms.

Raises when the schedule cannot fire within four years, which is what an impossible date looks like: 0 0 30 2 * is the 30th of February.

next(parse("0 9 * * mon"), time.now())