Skip to content

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

@maciektr

Description

@maciektr

Consider following example

%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)
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:

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions