recurring_events v0.1.0 RecurringEvents.Date
Helper module responsible for common date manipulations.
Summary
Functions
Compares two dates, time if provided will be ignored
Returns last daty of the month for provided date
Returns next day of the week
Returns previous day of the week
Shifts date by :days
, :weeks
, :months
and :years
Shifts week days
Returns week day of provided date
Functions
Compares two dates, time if provided will be ignored.
Example
iex> RecurringEvents.Date.compare(~D[2017-02-05], ~D[2017-02-01])
:gt
iex> RecurringEvents.Date.compare(~D[2017-02-01], ~D[2017-02-05])
:lt
iex> RecurringEvents.Date.compare(~N[2017-02-05 12:00:00],
...> ~N[2017-02-05 18:21:11])
:eq
Returns last daty of the month for provided date.
Example
iex> RecurringEvents.Date.last_day_of_the_month(~D[2017-02-04])
28
Returns next day of the week
Example
iex> RecurringEvents.Date.next_week_day(:friday)
:saturday
Returns previous day of the week
Example
iex> RecurringEvents.Date.prev_week_day(:wednesday)
:tuesday
Shifts date by :days
, :weeks
, :months
and :years
Example
iex> RecurringEvents.Date.shift_date(~D[2011-02-04], 4, :days)
~D[2011-02-08]
iex> RecurringEvents.Date.shift_date(~D[2011-02-04], 2, :years)
~D[2013-02-04]
Shifts week days
Example
iex> RecurringEvents.Date.shift_week_day(:monday, -3)
:friday