Cldr.Calendar.interval
You're seeing just the function
interval
, go back to Cldr.Calendar module for more information.
Specs
interval( date_from :: Date.t(), date_to_or_count :: Date.t() | non_neg_integer(), precision() ) :: [Date.t()]
Returns an Enumerable
list of dates of a given precision
of either :years
, :quarters
, :months
, :weeks
or
:days
Arguments
date_from
is a anyDate.t
that is the start of the sequencedate_to_or_count
is upper bound of the sequence as aDate.t
or the number of dates in the sequence to be generatedprecision
is one of:years
,:quarters
,:months
,:weeks
or:days
The sequence is generated starting with date_from
until the next date
in the sequence would be after date_to
.
Notes
The sequence can be in ascending or descending date order
based upon whether date_from
is greater than date_to
.
Returns
- A list of dates
Examples
iex> d = ~D[2019-01-31]
~D[2019-01-31]
iex> d2 = ~D[2019-05-31]
~D[2019-05-31]
iex> Cldr.Calendar.interval d, 3, :months
[~D[2019-01-31], ~D[2019-02-28], ~D[2019-03-31]]
iex> Cldr.Calendar.interval d, d2, :months
[~D[2019-01-31], ~D[2019-02-28], ~D[2019-03-31],
~D[2019-04-30], ~D[2019-05-31]]