feat() uses ical tz translation for windows

pull/79/head
Martin Eigenmann 2021-03-28 11:38:42 +02:00
rodzic fee7f429b8
commit 7720a49dac
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 069D1EE3806CA368
1 zmienionych plików z 7 dodań i 0 usunięć

Wyświetl plik

@ -14,6 +14,8 @@ from icalendar import Calendar
from icalendar.prop import vDDDLists, vText
from pytz import timezone
from icalendar.windows_to_olson import WINDOWS_TO_OLSON
def now():
"""
@ -267,6 +269,9 @@ def parse_events(content, start=None, end=None, default_span=timedelta(days=7)):
# Keep track of the timezones defined in the calendar
timezones = {}
if 'X-WR-TIMEZONE' in calendar:
timezones[str(calendar['X-WR-TIMEZONE'])] = str(calendar['X-WR-TIMEZONE'])
for c in calendar.walk('VTIMEZONE'):
name = str(c['TZID'])
try:
@ -282,6 +287,8 @@ def parse_events(content, start=None, end=None, default_span=timedelta(days=7)):
# assume it applies globally, otherwise UTC
if len(timezones) == 1:
cal_tz = gettz(list(timezones)[0])
if not cal_tz and timezone in WINDOWS_TO_OLSON:
cal_tz = gettz(WINDOWS_TO_OLSON[str(c['TZID'])])
else:
cal_tz = UTC