mule/cron/expression

Cron expression parsing and matching — a port of Oban.Cron.Expression (cron/expression.ex). Replaces the clockwork dependency: the reference parser supports the @-nicknames (@daily, @reboot, …), named weekday/month ranges (MON-FRI), and validates range bounds — all of which clockwork’s five-field-only grammar rejected or silently accepted.

Only parse/now/is_reboot are ported: next_at/last_at exist in Elixir for Pro’s DynamicCron and the @reboot uptime calculation, and nothing in the OSS runtime calls them.

Types

A parsed expression: the value sets each date/time component must hit, plus the reboot flag (@reboot matches once at boot, never by clock). input keeps the ORIGINAL string for the job meta’s cron_expr.

pub opaque type Expression

Values

pub fn input(expression expression: Expression) -> String

The original expression string, for meta.cron_expr (Elixir stores the input, not the expansion — a @daily job’s meta says @daily).

pub fn is_reboot(expression expression: Expression) -> Bool

@reboot entries fire once at startup and are then discarded by the plugin (cron.ex discard_reboots).

pub fn now(
  expression expression: Expression,
  date date: calendar.Date,
  time time: calendar.TimeOfDay,
) -> Bool

Does the expression match this calendar minute (Expression.now?/2)? Seconds are ignored — the plugin evaluates once per minute. @reboot always matches (the plugin discards it after its first evaluation).

pub fn parse(input input: String) -> Result(Expression, String)

Parse an expression (Expression.parse/1): the seven nicknames plus the standard five-field form with literals, *, ranges, steps, range-steps, comma lists, and JAN-DEC / SUN-SAT names. Errors carry the same messages as Elixir’s ArgumentErrors.

Search Document