You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
python3
Python 3.5.3 (default, Nov 4 2021, 15:29:10)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dateutil.tz import *;
>>> tz = tzical('/home/me/cln2stbb4dk6ur39chgnig37e9nnas1eeon66obccln68obi5pjmurr7dhiisorfdk@virtual.ics')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/me/.local/lib/python3.5/site-packages/dateutil/tz/tz.py", line 1279, in __init__
self._parse_rfc(fobj.read())
File "/home/me/.local/lib/python3.5/site-packages/dateutil/tz/tz.py", line 1449, in _parse_rfc
raise ValueError("unsupported property: "+name)
ValueError: unsupported property: X-LIC-LOCATION
Any suggestions? The ics file i'm trying to import is just a google calendar standard one of public holidays.
The text was updated successfully, but these errors were encountered:
I ran into the same issue myself -- the problem is that the tzical class doesn't support non-standard properties, as defined by RFC 5545. Google Calendar is one such vendor that likes to add these experimental properties into their timezone definitions (and their icalendar files in general); here is a simple example that reproduces this issue:
from dateutil.tz import tzical
from io import StringIO
# timezone definition from a Google Calendar ICS event
vtimezone = "BEGIN:VTIMEZONE\r\nTZID:America/New_York\r\nX-LIC-LOCATION:America/New_York\r\nBEGIN:DAYLIGHT\r\nDTSTART:19700308T020000\r\nRRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3\r\nTZNAME:EDT\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0400\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nDTSTART:19701101T020000\r\nRRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11\r\nTZNAME:EST\r\nTZOFFSETFROM:-0400\r\nTZOFFSETTO:-0500\r\nEND:STANDARD\r\nEND:VTIMEZONE"
with StringIO(vtimezone) as tz_file:
tz = tzical(tz_file) # ValueError
Applications MUST ignore x-param and iana-param values they don't recognize.
and additionally includes x-prop as a valid property of a VTIMEZONE component (source), so I believe that this is a bug that dateutil should handle. It should be pretty simple to fix this; I'll make a PR.
In the meantime, you can get your code working by parsing out the non-standard properties before passing your file to tzical:
import re
from dateutil.tz import tzical
from io import StringIO
timezone_file = "your_timezone_file.ics"
with open(timezone_file, "r") as f:
vtimezone = f.read()
# NOTE: this doesn't handle line folding
# If you want to handle experimental attributes that are on lines that may
# be folded, refer to this code:
# https://github.com/dateutil/dateutil/blob/master/src/dateutil/tz/tz.py#L1335
clean_vtimezone = re.sub("X-.+?(\r\n|\n)", "", vtimezone)
with StringIO(clean_vtimezone) as tz_file:
tz = tzical(tz_file)
Any suggestions? The ics file i'm trying to import is just a google calendar standard one of public holidays.
The text was updated successfully, but these errors were encountered: