diff --git a/CHANGES.rst b/CHANGES.rst index 3db0a192..cc25a79b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,15 @@ Changelog .. towncrier release notes start +5.1.4 (2024-06-07) +------------------ + +Bug fixes: + + +- Don't error out on 'Africa/Abidjan' timezone [gyst] (#393) + + 5.1.3 (2024-05-30) ------------------ diff --git a/plone/app/event/ical/exporter.py b/plone/app/event/ical/exporter.py index bd9f8156..f313903c 100644 --- a/plone/app/event/ical/exporter.py +++ b/plone/app/event/ical/exporter.py @@ -111,7 +111,6 @@ def add_to_zones_map(tzmap, tzid, dt): if tzid.lower() == "utc" or not is_datetime(dt): # no need to define UTC nor timezones for date objects. return tzmap - null = datetime(1, 1, 1) tz = pytz.timezone(tzid) transitions = getattr(tz, "_utc_transition_times", None) if not transitions: @@ -125,7 +124,7 @@ def add_to_zones_map(tzmap, tzid, dt): # datetime, which wouldn't create a match within the max-function. this # way we get the maximum transition time which is smaller than the # given datetime. - transition = max(transitions, key=lambda item: item if item <= dtzl else null) + transition = max(transitions, key=lambda item: item if item <= dtzl else dt.min) # get previous transition to calculate tzoffsetfrom idx = transitions.index(transition) @@ -133,10 +132,10 @@ def add_to_zones_map(tzmap, tzid, dt): prev_transition = transitions[prev_idx] def localize(tz, dt): - if dt is null: + if dt is datetime.min: # dummy time, edge case - # (dt at beginning of all transitions, see above.) - return null + # (dt at beginning of all transitions) + return dt.min return pytz.utc.localize(dt).astimezone(tz) # naive to utc + localize transition = localize(tz, transition) diff --git a/plone/app/event/tests/test_icalendar.py b/plone/app/event/tests/test_icalendar.py index c68e4ada..c3a30eb1 100644 --- a/plone/app/event/tests/test_icalendar.py +++ b/plone/app/event/tests/test_icalendar.py @@ -1,6 +1,7 @@ from datetime import datetime from plone.app.event import base from plone.app.event.dx.traverser import OccurrenceTraverser as OccTravDX +from plone.app.event.ical.exporter import add_to_zones_map from plone.app.event.ical.importer import ical_import from plone.app.event.testing import make_fake_response from plone.app.event.testing import PAEventDX_FUNCTIONAL_TESTING @@ -499,3 +500,7 @@ def test_import_from_ics__sync_keep_theirs(self): self.assertNotEqual(desc21, desc22) self.assertTrue(start21 < start22) self.assertTrue(end21 < end22) + + def test_add_to_zones_map(self): + tzmap = add_to_zones_map({}, "Africa/Abidjan", datetime(2013, 1, 1, 0, 0)) + self.assertTrue("Africa/Abidjan" in tzmap) diff --git a/setup.py b/setup.py index 7fd5ed78..bdc8fb2c 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup -version = "5.1.4.dev0" +version = "5.1.5.dev0" long_description = "\n\n".join(