View Source Crontab.CronExpression.Parser (crontab v1.1.13)

Parse string like * * * * * * to a %Crontab.CronExpression{}.

Link to this section Summary

Functions

Parse string like * * * * * * to a %CronExpression{}.

Parse string like * * * * * * to a %CronExpression{}.

Link to this section Types

@type result() :: {:ok, Crontab.CronExpression.t()} | {:error, binary()}

Link to this section Functions

Link to this function

parse(cron_expression, extended \\ false)

View Source
@spec parse(binary(), boolean()) :: result()

Parse string like * * * * * * to a %CronExpression{}.

examples

Examples

iex> Crontab.CronExpression.Parser.parse "* * * * *"
{:ok,
  %Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*]}}

iex> Crontab.CronExpression.Parser.parse "* * * * *", true
{:ok,
  %Crontab.CronExpression{extended: true, day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*], second: [:*]}}

iex> Crontab.CronExpression.Parser.parse "fooo"
{:error, "Can't parse fooo as minute."}
Link to this function

parse!(cron_expression, extended \\ false)

View Source
@spec parse!(binary(), boolean()) :: Crontab.CronExpression.t() | no_return()

Parse string like * * * * * * to a %CronExpression{}.

examples

Examples

iex> Crontab.CronExpression.Parser.parse! "* * * * *"
%Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*]}

iex> Crontab.CronExpression.Parser.parse! "* * * * *", true
%Crontab.CronExpression{extended: true, day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*], second: [:*]}

iex> Crontab.CronExpression.Parser.parse! "fooo"
** (RuntimeError) Can't parse fooo as minute.