-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly deal with non-existent recurrences #681
Comments
I share your interpretation, and Python with the |
Oh, good to hear. You mean regarding omitting vs ignoring recurrences, right? I removed the test case from the description though, because I think my interpretation regarding how to adjust nonexistent times could be wrong. |
Yes Although you remove the test case from the description, it would be good to include it in the repo together with the reasoning for this implementation. Very nice finding BTW |
Gave your examples another try with Python using import icalendar
from datetime import datetime
from dateutil.rrule import rrulestr
import pytz
# Create a calendar and event
cal = icalendar.Calendar()
event = icalendar.Event()
# Define the event properties
berlin_tz = pytz.timezone('Europe/Berlin')
dtstart = berlin_tz.localize(datetime(2025, 3, 29, 2, 30))
event.add('dtstart', dtstart)
event.add('rrule', {'FREQ': 'DAILY', 'COUNT': 2})
# Add the event to the calendar
cal.add_component(event)
# Extract the RRULE and DTSTART
rrule = event.get('rrule').to_ical().decode()
dtstart = event.get('dtstart').dt
# Calculate occurrences
rule = rrulestr(rrule, dtstart=dtstart)
occurrences = list(rule)
# Print occurrences
for occ in occurrences:
print(occ) Output (in both cases):
[Edit] |
Very interesting, thanks for testing! Obviously
|
Yes, let's stick to "our way". |
RFC 5545 section 3.3.10 seems to specify conflicting rules regarding how to deal with non-existent recurrences.
Recurrence rules may generate recurrence instances with an invalid
date(e.g., February 30) or nonexistent local time(e.g., 1:30 AM
on a day where the local time is moved forward by an hour at 1:00
AM). Such recurrence instances MUST be ignored and MUST NOT be
counted as part of the recurrence set.
If the computed local start time of a recurrence instance does not
exist, or occurs more than once, for the specified time zone, the
time of the recurrence instance is interpreted in the same manner
as an explicit DATE-TIME value describing that date and time, as
specified in Section 3.3.5.
My interpretation would be that 1) applies to 'BY' rules, a rule like
would generate
20250330T003000,20250330T043000
, because20250330T023000
doesn't exist and MUST be ignored.On the other hand something like
would generate
20250329T023000,20250330T033000
, because20250330T023000
must be treated according to section 3.3.5, which requires the previous tz offset to be applied.According to my interpretation, individual nonexistent
BY
rules would be ignored but whole intervals wouldn't. But that's just a guess at this time.Consider the following test case. Which values would be expected if DTSTART or DTEND are nonexistent?
The text was updated successfully, but these errors were encountered: