pbogut / recurring_events

Elixir library for dealing with recurring events
MIT License
26 stars 8 forks source link

Support for negative counts #21

Closed voughtdq closed 1 year ago

voughtdq commented 3 years ago

I'd like to add support for negative values for count.

For example:

iex(1)> alias RecurringEvents, as: RR
RecurringEvents
iex(2)> rule = %{date_start: ~D[2020-12-22], by_month_day: 1, freq: :monthly}
%{date_start: ~D[2020-12-22], by_month_day: 1, freq: :monthly}
iex(3)> RR.take(rule, -3)
[[~D[2020-12-22], ~D[2020-12-01], ~D[2020-11-01]]

Any tips on where to look to add support for this?

I started looking in RecurringEvents.Date but I'm wondering if there's a better place to start.

pbogut commented 3 years ago

You can have a look at by_pump and by_checker. Pump is inflating results and checker is filtering out wrong ones. I don`t remember exactly how it was done, but I think You would have to pump dates in other direction, not sure if checker would have to also be changed. Surely its not an easy one.