bug: wrong event if UNTIL< DTSTART
zoifar opened this issue · 8 comments
Describe the bug
If UNTIL< DTSTART then a wrong event is returned.
To Reproduce
ical_string="""BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTAMP:20231102T221721Z
DTSTART;VALUE=DATE:20231002
DTEND;VALUE=DATE:20231009
SUMMARY:test123
CATEGORIES:other
SUBCALENDAR-NAME:test
EVENT-ID:538924
EVENT-ALLDAY:true
RRULE:FREQ=WEEKLY;UNTIL=20231001;INTERVAL=2;BYDAY=MO
CREATED:20231102T221633Z
LAST-MODIFIED:20231102T221716Z
TRANSP:TRANSPARENT
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR"""
calendar = icalendar.Calendar.from_ical(ical_string)
events=recurring_ical_events.of(calendar).at(2023)
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:20231102T221721Z
DTSTART;VALUE=DATE:20231002
DTEND;VALUE=DATE:20231009
SUMMARY:test123
CATEGORIES:other
SUBCALENDAR-NAME:test
EVENT-ID:538924
EVENT-ALLDAY:true
RRULE:FREQ=WEEKLY;UNTIL=20231001;INTERVAL=2;BYDAY=MO
CREATED:20231102T221633Z
LAST-MODIFIED:20231102T221716Z
TRANSP:TRANSPARENT
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
Expected behavior
No events should be returned.
Console output
start 2023-10-02 duration 7 days, 0:00:00
Version:
2.1.0
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.
@zoifar thanks for reporting this. It seems unusual to not remove the event at all. Can you tell me more about the background of where this is generated? The until value often is on a valid repetition date, in this example it is not. I just want to be sure that when this becomes expected behavior that there is a general expectation of ICS functioning like this. Maybe, there is something in the spec... If it is a single person's expectation, it can still be implemented.
I definitely like that you caught a case I would not even have thought about!
@niccokunzmann, this is generated by atlassian confluence calendar when the first event in series and all future instances are deleted.
Thanks, that makes sense to me. Would you like to give it a go?
What happens if you edit a recurrence and then delete the whole event series?
What happens if you edit a recurrence and then delete the whole event series?
If you edit a recurrence and then delete the whole event series, than no events are present in ICS file.
I am not sure if all special cases are covered as there might also be edited recurrences. Either way, you can test with
pip install git+https://github.com/niccokunzmann/python-recurring-ical-events
I think, this issue can be closed and a new version released.
What are your thoughts?
It works. Thank you. This issue can be closed.
This is included in 2.1.1