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
95 stars 22 forks source link

bug: events duplicated in v3.1.0. #164

Closed zoifar closed 2 months ago

zoifar commented 2 months ago

Duplicated instances of the same event are returned in v3.1.0. The bug is not present in v2.1.3.

To Reproduce

import recurring_ical_events
import icalendar
ical_string="""BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTAMP:20240821T032819Z
DTSTART;VALUE=DATE:20240401
DTEND;VALUE=DATE:20240408
SUMMARY:test123
CATEGORIES:other
UID:111
ORGANIZER:aaa
RRULE:FREQ=WEEKLY;INTERVAL=3;BYDAY=MO
CREATED:20240311T051101Z
LAST-MODIFIED:20240311T051101Z
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20240821T032820Z
DTSTART;VALUE=DATE:20240826
DTEND;VALUE=DATE:20240902
SUMMARY:test123
CATEGORIES:other
UID:111
ORGANIZER:aaa
RRULE:FREQ=WEEKLY;INTERVAL=3;BYDAY=MO
RECURRENCE-ID;VALUE=DATE:20240826
CREATED:20240729T125457Z
LAST-MODIFIED:20240729T125457Z
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20240821T032820Z
DTSTART;VALUE=DATE:20240826
DTEND;VALUE=DATE:20240902
SUMMARY:test123
CATEGORIES:other
UID:111
ORGANIZER:aaa
RRULE:FREQ=WEEKLY;INTERVAL=3;BYDAY=MO
RECURRENCE-ID;VALUE=DATE:20240826
CREATED:20240729T125551Z
LAST-MODIFIED:20240729T125551Z
SEQUENCE:1
END:VEVENT
END:VCALENDAR
""" 

calendar = icalendar.Calendar.from_ical(ical_string)
events=recurring_ical_events.of(calendar).at([2024,8])

for event in events:
    start = event["DTSTART"].dt
    duration = event["DTEND"].dt - event["DTSTART"].dt
    print("start {} duration {}".format(start, duration))

ICS file

BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTAMP:20240821T032819Z
DTSTART;VALUE=DATE:20240401
DTEND;VALUE=DATE:20240408
SUMMARY:test123
CATEGORIES:other
UID:111
ORGANIZER:aaa
RRULE:FREQ=WEEKLY;INTERVAL=3;BYDAY=MO
CREATED:20240311T051101Z
LAST-MODIFIED:20240311T051101Z
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20240821T032820Z
DTSTART;VALUE=DATE:20240826
DTEND;VALUE=DATE:20240902
SUMMARY:test123
CATEGORIES:other
UID:111
ORGANIZER:aaa
RRULE:FREQ=WEEKLY;INTERVAL=3;BYDAY=MO
RECURRENCE-ID;VALUE=DATE:20240826
CREATED:20240729T125457Z
LAST-MODIFIED:20240729T125457Z
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20240821T032820Z
DTSTART;VALUE=DATE:20240826
DTEND;VALUE=DATE:20240902
SUMMARY:test123
CATEGORIES:other
UID:111
ORGANIZER:aaa
RRULE:FREQ=WEEKLY;INTERVAL=3;BYDAY=MO
RECURRENCE-ID;VALUE=DATE:20240826
CREATED:20240729T125551Z
LAST-MODIFIED:20240729T125551Z
SEQUENCE:1
END:VEVENT
END:VCALENDAR

Expected behavior

duplicated events are not returned

start 2024-08-05 duration 7 days, 0:00:00
start 2024-08-26 duration 7 days, 0:00:00

Console output

start 2024-08-05 duration 7 days, 0:00:00
start 2024-08-26 duration 7 days, 0:00:00
start 2024-08-26 duration 7 days, 0:00:00

Version: 3.1.0

pip list                         
Package               Version
--------------------- -----------
icalendar             5.0.13
pip                   23.3.1
python-dateutil       2.9.0.post0
pytz                  2024.1
recurring-ical-events 3.1.0
setuptools            69.0.2
six                   1.16.0
tzdata                2024.1
x-wr-timezone         0.0.7

Additional context

This is generated by atlassian confluence calendar.


We're using Polar.sh so you can upvote and help fund this issue. We receive the funding once the issue is completed & confirmed by you. Thank you in advance for helping prioritize & fund our work.

Fund with Polar

niccokunzmann commented 2 months ago

Thanks for the issues!

niccokunzmann commented 2 months ago

This is fixed in v3.1.1.