From 871af59add431cf13bcff6c74601bb12fc004c27 Mon Sep 17 00:00:00 2001 From: Nicco Kunzmann Date: Fri, 21 Jun 2024 18:27:24 +0100 Subject: [PATCH 1/2] Remove unused and untested code --- src/icalendar/__init__.py | 5 ---- src/icalendar/prop.py | 59 --------------------------------------- 2 files changed, 64 deletions(-) diff --git a/src/icalendar/__init__.py b/src/icalendar/__init__.py index 8b7203d6..138cf7a6 100644 --- a/src/icalendar/__init__.py +++ b/src/icalendar/__init__.py @@ -34,11 +34,6 @@ vUTCOffset, TypesFactory, ) -# useful tzinfo subclasses -from icalendar.prop import ( - FixedOffset, - LocalTimezone, -) # Parameters and helper methods for splitting and joining string with escaped # chars. from icalendar.parser import ( diff --git a/src/icalendar/prop.py b/src/icalendar/prop.py index 2ae5590d..61473219 100644 --- a/src/icalendar/prop.py +++ b/src/icalendar/prop.py @@ -40,12 +40,6 @@ from datetime import time from datetime import timedelta from datetime import tzinfo - -try: - from dateutil.tz import tzutc -except ImportError: - tzutc = None - from icalendar.caselessdict import CaselessDict from icalendar.parser import Parameters from icalendar.parser import escape_char @@ -70,19 +64,6 @@ WEEKDAY_RULE = re.compile(r'(?P[+-]?)(?P[\d]{0,2})' r'(?P[\w]{2})$') -#################################################### -# handy tzinfo classes you can use. -# - -ZERO = timedelta(0) -HOUR = timedelta(hours=1) -STDOFFSET = timedelta(seconds=-_time.timezone) -if _time.daylight: - DSTOFFSET = timedelta(seconds=-_time.altzone) -else: - DSTOFFSET = STDOFFSET -DSTDIFF = DSTOFFSET - STDOFFSET - def tzid_from_dt(dt: datetime) -> Optional[str]: """Retrieve the timezone id from the datetime object.""" @@ -98,46 +79,6 @@ def tzid_from_dt(dt: datetime) -> Optional[str]: return tzid -class FixedOffset(tzinfo): - """Fixed offset in minutes east from UTC. - """ - - def __init__(self, offset, name): - self.__offset = timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return ZERO - - -class LocalTimezone(tzinfo): - """Timezone of the machine where the code is running. - """ - - def utcoffset(self, dt): - return DSTOFFSET if self._isdst(dt) else STDOFFSET - - def dst(self, dt): - return DSTDIFF if self._isdst(dt) else ZERO - - def tzname(self, dt): - return _time.tzname[self._isdst(dt)] - - def _isdst(self, dt): - tt = (dt.year, dt.month, dt.day, - dt.hour, dt.minute, dt.second, - dt.weekday(), 0, -1) - stamp = _time.mktime(tt) - tt = _time.localtime(stamp) - return tt.tm_isdst > 0 - - class vBinary: """Binary property values are base 64 encoded. """ From 417c6fb88380715682334279b162ce2916fb414a Mon Sep 17 00:00:00 2001 From: Nicco Kunzmann Date: Fri, 21 Jun 2024 18:30:12 +0100 Subject: [PATCH 2/2] Log changes --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 92b2fc87..2d2fa66d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -33,6 +33,8 @@ Breaking changes: - Replaced ``pkg_resources.get_distribution`` with ``importlib.metadata`` in ``docs/conf.py`` to allow building docs on Python 3.12. +- Remove untested and broken ``LocalTimezone`` and ``FixedOffset`` tzinfo + sub-classes, see `Issue 67 `_ New features: