From e45ce94b7e20f953cc0246fbe1af814a7ccf473a Mon Sep 17 00:00:00 2001 From: Nicco Kunzmann Date: Wed, 5 Jun 2024 11:46:00 +0100 Subject: [PATCH] Rename fix_pytz_rrule_until -> fix_rrule_until --- src/icalendar/cal.py | 2 +- src/icalendar/timezone/pytz.py | 2 +- src/icalendar/timezone/tzp.py | 4 ++-- src/icalendar/timezone/zoneinfo.py | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/icalendar/cal.py b/src/icalendar/cal.py index a976981..17d65ef 100644 --- a/src/icalendar/cal.py +++ b/src/icalendar/cal.py @@ -571,7 +571,7 @@ class Timezone(Component): rrulestr = component['RRULE'].to_ical().decode('utf-8') rrule = dateutil.rrule.rrulestr(rrulestr, dtstart=rrstart) - tzp.fix_pytz_rrule_until(rrule, component) + tzp.fix_rrule_until(rrule, component) # constructing the timezone requires UTC transition times. # here we construct local times without tzinfo, the offset to UTC diff --git a/src/icalendar/timezone/pytz.py b/src/icalendar/timezone/pytz.py index 96af85b..dcbbdff 100644 --- a/src/icalendar/timezone/pytz.py +++ b/src/icalendar/timezone/pytz.py @@ -24,7 +24,7 @@ class PYTZ: """Whether the timezone is already cached by the implementation.""" return id in pytz.all_timezones - def fix_pytz_rrule_until(self, rrule, component): + def fix_rrule_until(self, rrule, component): """Make sure the until value works.""" if not {'UNTIL', 'COUNT'}.intersection(component['RRULE'].keys()): # pytz.timezones don't know any transition dates after 2038 diff --git a/src/icalendar/timezone/tzp.py b/src/icalendar/timezone/tzp.py index e91c774..e609906 100644 --- a/src/icalendar/timezone/tzp.py +++ b/src/icalendar/timezone/tzp.py @@ -53,9 +53,9 @@ class TZP: if not self.__provider.knows_timezone_id(component['TZID']): self.__tz_cache.setdefault(component['TZID'], component.to_tz()) - def fix_pytz_rrule_until(self, rrule, component) -> None: + def fix_rrule_until(self, rrule, component) -> None: """Make sure the until value works.""" - self.__provider.fix_pytz_rrule_until(rrule, component) + self.__provider.fix_rrule_until(rrule, component) def create_timezone(self, name: str, transition_times, transition_info) -> datetime.tzinfo: """Create a timezone from given information.""" diff --git a/src/icalendar/timezone/zoneinfo.py b/src/icalendar/timezone/zoneinfo.py index ab3dde3..40b04e1 100644 --- a/src/icalendar/timezone/zoneinfo.py +++ b/src/icalendar/timezone/zoneinfo.py @@ -32,5 +32,12 @@ class ZONEINFO: """Whether the timezone is already cached by the implementation.""" return id in self._available_timezones + def fix_rrule_until(self, rrule, component): + """Make sure the until value works.""" + if not {'UNTIL', 'COUNT'}.intersection(component['RRULE'].keys()): + # zoninfo does not know any transition dates after 2038 + rrule._until = datetime(2038, 12, 31, tzinfo=pytz.UTC) + + __all__ = ["ZONEINFO"]