You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Timezone.from_tzinfo(): Use RRULE rather than RDATE in VTIMEZONE? #2074
We discovered in python-caldav/caldav#852 that the size of the VTIMEZONE wasn't constant. RDATE is used in the VTIMEZONE to indicate the DST, and the VTIMEZONE covers the range of the calendar.
It's being claimed that year 9999 is a common "no end"-sentinel. While I've never seen that myself, I suppose such systems exist. If something starts in the current decade and ends in year 9999, the VTIMEZONE will be hundreds of kilobytes big.
Wouldn't it be better to use RRULE?
Longer analysis by Claude Opus 5.5 under the line.
Timezone.from_tzinfo() / Timezone.from_tzid() describe every transition between first_date and last_date as an RDATE, and nothing after last_date. That gives two problems for a caller that has to cover dates far in the future:
The size grows linearly with the range. For Europe/Berlin on current main (7.3.1.dev188):
last_date
to_ical() size
2038-01-01 (default)
2343 bytes
2100-01-01
4405 bytes
2200-01-01
7737 bytes
2500-01-01
17727 bytes
9998-01-01
267389 bytes
Year 9999 is a common "no end" sentinel, so a caller that stretches the range to the dates in its calendar ends up with very large VTIMEZONEs.
Times after last_date get the last offset. A client that reads the VTIMEZONE rather than resolving the TZID shows summer-time dates past last_date an hour off:
(A custom TZID is used only so that to_tz() reads the VTIMEZONE instead of looking Europe/Berlin up.)
Suggestion: after the last irregular transition, emit one STANDARD and one DAYLIGHT observance with an open-ended RRULE for the rule that keeps repeating. That is what most VTIMEZONEs in the wild do, e.g. RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU. The rule is available: TZif files end with a POSIX TZ string (e.g. CET-1CEST,M3.5.0,M10.5.0/3) for exactly this purpose. Inferring it from two consecutive years of transitions would also work for pytz and other tzinfo objects. The VTIMEZONE would then be small and correct for any future date. last_date would only matter for zones without a recurring rule.
Context: python-caldav adds missing VTIMEZONEs to the objects it creates (python-caldav/caldav#852). It now stretches first_date/last_date to the dates in the object, but has to cap last_date at the end of 2200 because of the size, so summer-time dates after 2200 are an hour off in clients that read the VTIMEZONE.
Activity
github-actions commentedon Nov 8, 2026
Thanks for the issue, @tobixen! A maintainer will review it shortly.