Skip to content

Commit

Permalink
Merge pull request #639 from niccokunzmann/issue-67
Browse files Browse the repository at this point in the history
Remove unused and untested code
  • Loading branch information
stevepiercy committed Jun 22, 2024
2 parents 0cc0e1b + 417c6fb commit 8f23cf8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 64 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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 <https://github.com/collective/icalendar/issues/67>`_

New features:

Expand Down
5 changes: 0 additions & 5 deletions src/icalendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
59 changes: 0 additions & 59 deletions src/icalendar/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -70,19 +64,6 @@
WEEKDAY_RULE = re.compile(r'(?P<signal>[+-]?)(?P<relative>[\d]{0,2})'
r'(?P<weekday>[\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."""
Expand All @@ -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.
"""
Expand Down

0 comments on commit 8f23cf8

Please sign in to comment.