lpil / lpil/icalendar

`Recurrence.get_recurrences/2` returns invalid dates after passing leap day once in the recurrence stream

Open
#58 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Elixir
Stars
106
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Consider following example
```elixir
%ICalendar.Event{dtstart: ~U[2020-12-30 01:01:01Z], rrule: %{freq: "MONTHLY"}}
|> ICalendar.Recurrence.get_recurrences(~U[2022-01-01 01:01:01Z])
```
The first recurrence is `2021-01-30`
Then, as there is no 30th day in February, `Timex.shift` returns `2021-02-28` (as describe in [docs](https://hexdocs.pm/timex/Timex.html?#shift/2-shifting-and-leap-days))
All recurrences returned from stream after that point to 28th day of a month (for instance, the third one is 2021-03-28), which I believe is invalid.

To reproduce run:
```elixir
ICalendar.Recurrence.get_recurrences(
%ICalendar.Event{dtstart: ~U[2020-12-30 01:01:01Z], rrule: %{freq: "MONTHLY"}},
~U[3000-01-01 01:01:01Z]
)
|> Enum.take(3)
|> IO.inspect()
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at ICalendar.Recurrence.get_recurrences/2 and reproduce the issue with the provided Event, monthly rule, and Enum.take(3) example. Check how Timex.shift handles the February transition; done means later monthly recurrences retain the intended day instead of remaining on the 28th.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.