niccokunzmann / python-recurring-ical-events

Python library to calculate recurrence times of events, todos and journals based on icalendar RFC5545
https://pypi.org/project/recurring-ical-events/
GNU Lesser General Public License v3.0
93 stars 21 forks source link

bug: Monthly recurrence for yearly events when BYMONTHDAY is used #41

Closed alexgit2k closed 4 years ago

alexgit2k commented 4 years ago

Describe the bug If not only "FREQ=YEARLY" is set for yearly events, but also the parameter "BYMONTHDAY=..." - like the Windows 10 calendar app is doing - then recurring_ical_events converts them to monthly events.

To Reproduce

#!/usr/bin/python3

import icalendar, recurring_ical_events_master

start_date = (2020, 7, 1)
end_date = (2020, 10, 1)
file = 'test.ics'

ical_string = open(file,'r').read();
calendar = icalendar.Calendar.from_ical( ical_string )
events = recurring_ical_events_master.of(calendar).between(start_date, end_date)
for event in events:
    print("{} {}".format(event["DTSTART"].dt, event["SUMMARY"]))

ICS file

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN

BEGIN:VEVENT
DTSTART;VALUE=DATE:20200716
DTEND;VALUE=DATE:20200717
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTHDAY=16
SUMMARY:Yearly Birthday Wrong
END:VEVENT

BEGIN:VEVENT
DTSTART;VALUE=DATE:20200716
DTEND;VALUE=DATE:20200717
RRULE:FREQ=YEARLY
SUMMARY:Yearly Birthday Okay
END:VEVENT

END:VCALENDAR

Expected behavior Events with frequency yearly should still be yearly.

Console output

2020-07-16 Yearly Birthday Wrong
2020-08-16 Yearly Birthday Wrong
2020-09-16 Yearly Birthday Wrong
2020-07-16 Yearly Birthday Okay

Version: master-Branch (v0.1.18b + further commits)

niccokunzmann commented 4 years ago

Hi @alexgit2k and thanks for reporting this. To see where the issue lies, I think, the next step would be to feed the string FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTHDAY=16 to the rrulestr function of dateutil and see if it provides the correct values. If yes, the bug is here. If not, the bug is in dateutil.rrule.

from dateutil.rrule import rrulestr
alexgit2k commented 4 years ago

You were right, its an error in rrulestr of dateutil. I reported it there: dateutil/dateutil/issues/1072

Thanks, closing this issue.