Rename fix_pytz_rrule_until -> fix_rrule_until

pull/623/head
Nicco Kunzmann 2024-06-05 11:46:00 +01:00
rodzic 864a144861
commit e45ce94b7e
4 zmienionych plików z 11 dodań i 4 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -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."""

Wyświetl plik

@ -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"]