View Source Crontab.DateChecker (crontab v1.1.14)
This module is used to check a Crontab.CronExpression
against a given date.
Summary
Types
@type date() :: NaiveDateTime.t() | DateTime.t()
Functions
@spec matches_date?(cron_expression :: Crontab.CronExpression.t(), date :: date()) :: boolean() | no_return()
@spec matches_date?( condition_list :: Crontab.CronExpression.condition_list(), date :: date() ) :: boolean()
Check a condition list against a given date.
Examples
iex> Crontab.DateChecker.matches_date? %Crontab.CronExpression{minute: [{:"/", :*, 8}]}, ~N[2004-04-16 04:08:08]
true
iex> Crontab.DateChecker.matches_date? %Crontab.CronExpression{minute: [{:"/", :*, 9}]}, ~N[2004-04-16 04:07:08]
false
iex> Crontab.DateChecker.matches_date? %Crontab.CronExpression{reboot: true}, ~N[2004-04-16 04:07:08]
** (RuntimeError) Special identifier @reboot is not supported.
iex> Crontab.DateChecker.matches_date? [{:hour, [{:"/", :*, 4}, 7]}], ~N[2004-04-16 04:07:08]
true
@spec matches_date?( interval :: Crontab.CronExpression.interval(), condition_list :: Crontab.CronExpression.condition_list(), date :: date() ) :: boolean()
Check a condition against a given date.
Examples
iex> Crontab.DateChecker.matches_date? :hour, [{:"/", :*, 4}, 7], ~N[2004-04-16 04:07:08]
true
iex> Crontab.DateChecker.matches_date? :hour, [8], ~N[2004-04-16 04:07:08]
false