Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid timezone parsing #54

Closed
AlexTalker opened this issue Jun 12, 2019 · 1 comment · Fixed by #80
Closed

Invalid timezone parsing #54

AlexTalker opened this issue Jun 12, 2019 · 1 comment · Fixed by #80

Comments

@AlexTalker
Copy link

I'm trying to parse iCalendar file, generated by Microsoft Outlook 2016.
While parsing itself works fine, I did stuck with the timezone.

The calendar header(excluding events) looks like this:

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-CALSTART:20190527T093000Z
X-CALEND:20190614T170000Z
X-CLIPSTART:20190430T210000Z
X-CLIPEND:20190616T210000Z
X-WR-RELCALID:{0000002E-65C8-5317-F094-6C7ABA69683A}
X-WR-CALNAME:Schedule
BEGIN:VTIMEZONE
TZID:Russian Standard Time
BEGIN:STANDARD
DTSTART:16010101T000000
TZOFFSETFROM:+0300
TZOFFSETTO:+0300
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:Unnamed Time Zone 1
BEGIN:STANDARD
DTSTART:16010101T000000
TZOFFSETFROM:+0300
TZOFFSETTO:+0300
END:STANDARD
END:VTIMEZONE

As dateutil.tz.gettz() returns None to Russian Standard Time in parser: https://github.com/irgangla/icalevents/blob/master/icalevents/icalparser.py#L224
it all falls back to the UTC. However, why don't you check offset value?
From what it seems, solemnly relying on value of TZID is not safe.
Also, you might provide ability to override timezone via argument of events function.

@Zachu
Copy link

Zachu commented Jan 26, 2021

Noticed this also with FLE Standard Time. I assume actually that the problem is in https://github.com/irgangla/icalevents/blob/89f3cf7155d3458a157acde9c9e8a3ea3fa3f68d/icalevents/icalparser.py#L276-L281
I think the code assumes to always get a real timezone from gettz() but it returns None when it hits something it doesn't know of. So checking the gettz output should fix this.

>>> from dateutil.tz import gettz
>>> type(gettz('Russian Standard Time'))
<class 'NoneType'>
>>> type(gettz('FLE Standard Time'))
<class 'NoneType'>
>>> type(gettz('UTC'))
<class 'dateutil.tz.tz.tzfile'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants