pbogut / recurring_events

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

Plans for "Nth Week of Month"? #1

Closed jessejanderson closed 6 years ago

jessejanderson commented 7 years ago

Love the library - I was trying to do something similar and this is much better than what I was working on. :)

I saw some of the tests are tagged pending (the ones having to do with 1st-week-of-month, last-week-of-month, etc). Are there plans to complete those features?

I poked around the code a little, it seems like maybe a by_week rule that accepted [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] might be a nice way to add it to the API (freq: :monthly required?)?

pbogut commented 7 years ago

Glad you like it :slightly_smiling_face: I've basically ripped of the examples from the iCal recurring specification and I've put them as tests. Ones that are not implemented are pending. I want to implement those rules but can't commit to a date. To be honest, a project that I need this library for is not requiring those rules, that is why it's not implemented yet.

I think the case you are talking about should be covered by BYSETPOS (not implemented)? Take a look here. Then rule could look like %{freq: :monthly, by_day: :monday, by_pos: -1} or simillar. What exact use case you are looking for?

pbogut commented 6 years ago

It's not supporting week number in the month exactly (it would be tricky to say whats a week in month anyway) but it supports complete rrule, so you can do thing like [{-1, :monday},{-1, :tuesday},...] for the last week days of the month, or use :by_set_position. I'm not sure what exact use case you had but I guess it should be supported now if you still need it (doubtedly, but well..).