Merge branch 'recurring-events-and-timezones' into recurring-events-and-timezones-pipenv-01

pull/97/head
Martin Eigenmann 2021-11-12 11:13:16 +01:00
commit 2117c0da04
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 069D1EE3806CA368
3 zmienionych plików z 4378 dodań i 0 usunięć

Wyświetl plik

@ -449,6 +449,21 @@ def parse_events(content, start=None, end=None, default_span=timedelta(days=7)):
elif e.end >= start and e.start <= end:
exdate = "%04d%02d%02d" % (e.start.year, e.start.month, e.start.day)
if exdate not in exceptions:
if (
type(e.recurrence_id) == datetime
and type(component.get("dtstart").dt) == datetime
):
naive = datetime(
e.recurrence_id.year,
e.recurrence_id.month,
e.recurrence_id.day,
e.recurrence_id.hour,
e.recurrence_id.minute,
e.recurrence_id.second,
)
e.recurrence_id = normalize(
naive, tz=component.get("dtstart").dt.tzinfo
)
found.append(e)
result = found.copy()

Plik diff jest za duży Load Diff

Wyświetl plik

@ -591,3 +591,19 @@ class ICalEventsTests(unittest.TestCase):
self.assertEqual(
e1.start.tzinfo, gettz("Europe/Zurich"), "check tz as specified in calendar"
)
def test_recurring_override(self):
ical = "test/test_data/recurring_override.ics"
start = date(2021, 11, 23)
end = date(2021, 11, 24)
[e0, e1, e2] = icalevents.events(file=ical, start=start, end=end)
# Here all dates are in utc because the .ics has two timezones and this causes a transformation
self.assertEqual(e0.start, datetime(2021, 11, 23, 9, 0, tzinfo=UTC))
self.assertEqual(e1.start, datetime(2021, 11, 23, 10, 45, tzinfo=UTC))
self.assertEqual(
e2.start,
datetime(2021, 11, 23, 13, 0, tzinfo=UTC),
"moved 1 hour from 12:00 to 13:00",
)