Belay.CronExpr (Belay v1.0.0)

Copy Markdown View Source

Minimal five-field cron expressions: minute hour day-of-month month day-of-week.

Supports *, numbers, ranges (a-b), steps (*/n, a-b/n), lists (a,b,c), and the nicknames @hourly, @daily, @midnight, @weekly, @monthly. Day-of-week is 0-6 with 0 = Sunday (7 also accepted as Sunday).

Summary

Functions

Does the minute containing datetime (UTC) match?

Parse an expression. Returns {:ok, t} or {:error, reason}.

Parse an expression, raising ArgumentError when it is invalid.

Truncate a datetime to its minute slot.

Types

t()

@type t() :: %Belay.CronExpr{
  days: term(),
  hours: term(),
  minutes: term(),
  months: term(),
  source: term(),
  weekdays: term()
}

Functions

matches?(expr, datetime)

@spec matches?(t(), DateTime.t()) :: boolean()

Does the minute containing datetime (UTC) match?

parse(expression)

@spec parse(String.t()) :: {:ok, t()} | {:error, String.t()}

Parse an expression. Returns {:ok, t} or {:error, reason}.

parse!(expression)

@spec parse!(String.t()) :: t()

Parse an expression, raising ArgumentError when it is invalid.

slot(datetime)

@spec slot(DateTime.t()) :: DateTime.t()

Truncate a datetime to its minute slot.