recurring_events v0.2.0 RecurringEvents View Source
RecurringEvents is an Elixir library providing recurring events support (duh!).
It loosely follows iCal Recurrence rule specification RFC 2445.
Currently, it is ignoring time but if DateTime or NaiveDateTime structure is used time will be preserved (see below).
iex> RecurringEvents.take(~D[2016-12-07], %{freq: :daily}, 3)
[~D[2016-12-07], ~D[2016-12-08], ~D[2016-12-09]]
iex> RecurringEvents.take(~N[2016-01-17 12:21:06], %{freq: :weekly}, 2)
[~N[2016-01-17 12:21:06], ~N[2016-01-24 12:21:06]]
Currently supported rules
:count
- how many occurences should be return:interval
- how often recurrence rule repeats:freq
- this is the only required rule, possible values::yearly
,:monthly
,:weekly
,:daily
:week_start
- start day of the week, see:by_day
for possible values:by_month
- month number or list of month numbers:by_day
- day or list of days, possible values::monday
,:tuesday
,:wednesday
,:thursday
,:friday
,:saturday
,:sunday
. This rule can also accept tuples with occurrence number when used with:monthly
or:yearly
frequency (e.g.{3, :monday}
for 3rd Monday or{-2, :tuesday}
for 2nd to last Tuesday):by_month_day
- month day number or list of month day numbers:by_week_number
- number of the week in a year, first week should have at least 4 days,:week_start
may affect result of this rule
For more usage examples, please, refer to tests
Link to this section Summary
Functions
Returns list of recurring events based on date and rules
Returns stream of recurring events based on date and rules
Link to this section Functions
Returns list of recurring events based on date and rules
Example
iex> RecurringEvents.take(~D[2015-09-13], %{freq: :monthly}, 4)
[~D[2015-09-13], ~D[2015-10-13], ~D[2015-11-13], ~D[2015-12-13]]
Returns stream of recurring events based on date and rules
Example
iex> RecurringEvents.unfold(~D[2014-06-07], %{freq: :yearly})
...> |> Enum.take(3)
[~D[2014-06-07], ~D[2015-06-07], ~D[2016-06-07]]