crontab v0.8.0 Crontab.CronScheduler

This module provides the functionality to retrieve the next run date or the previous run date from a %Crontab.CronInterval{}.

Summary

Functions

This function provides the functionality to retrieve the next run date from a %Crontab.CronInterval{}

This function provides the functionality to retrieve the previous run date from a %Crontab.CronInterval{}

Types

direction()
direction() :: :increment | :decrement
result()
result() :: {:error, any} | {:ok, NaiveDateTime.t}

Functions

get_next_run_date(cron_interval, date, max_runs \\ 10000)

This function provides the functionality to retrieve the next run date from a %Crontab.CronInterval{}.

Examples

iex> Crontab.CronScheduler.get_next_run_date(%Crontab.CronInterval{}, ~N[2002-01-13 23:00:07])
{:ok, ~N[2002-01-13 23:00:00]}

iex> Crontab.CronScheduler.get_next_run_date(%Crontab.CronInterval{year: [{:/, :*, 9}]}, ~N[2002-01-13 23:00:07])
{:ok, ~N[2007-01-01 00:00:00]}
get_previous_run_date(cron_interval, date, max_runs \\ 10000)
get_previous_run_date(Crontab.ExtendedCronInterval.all_t, NaiveDateTime.t, integer) :: result

This function provides the functionality to retrieve the previous run date from a %Crontab.CronInterval{}.

Examples

iex> Crontab.CronScheduler.get_previous_run_date(%Crontab.CronInterval{}, ~N[2002-01-13 23:00:07])
{:ok, ~N[2002-01-13 23:00:00]}

iex> Crontab.CronScheduler.get_previous_run_date(%Crontab.CronInterval{year: [{:/, :*, 9}]}, ~N[2002-01-13 23:00:07])
{:ok, ~N[1998-12-31 23:59:00]}