shigoto_cron_parser (shigoto v1.9.10)

View Source

Parses standard 5-field cron expressions and checks if a given datetime matches. Fields: minute, hour, day-of-month, month, day-of-week.

Supported syntax per field:

  • * — any value
  • N — exact value
  • N-M — inclusive range
  • */N — step from start
  • N-M/S — step within range
  • N,M,O — comma-separated list (each element may be a value, range, or step)

Aliases: @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly.

Summary

Functions

Check if a calendar:datetime() matches a parsed cron expression.

Parse a 5-field cron expression or alias into a structured map.

Types

cron_expr()

-type cron_expr() ::
          #{minute := field(), hour := field(), dom := field(), month := field(), dow := field()}.

field()

-type field() :: star | {step, pos_integer()} | {values, [non_neg_integer()]}.

Functions

matches/2

-spec matches(cron_expr(), calendar:datetime()) -> boolean().

Check if a calendar:datetime() matches a parsed cron expression.

parse/1

-spec parse(binary()) -> {ok, cron_expr()} | {error, term()}.

Parse a 5-field cron expression or alias into a structured map.