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

dst_offset is not False #321

Open
monofox opened this issue Mar 23, 2021 · 3 comments
Open

dst_offset is not False #321

monofox opened this issue Mar 23, 2021 · 3 comments
Labels
tested and needs fix This pull request tests code but needs a contribution to fix the test - TDD

Comments

@monofox
Copy link

monofox commented Mar 23, 2021

Hi,

Figured out following issue on icalendar 4.0.7 from pypi.

ICS file:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
DTSTART;VALUE=DATE-TIME:20200329T030000
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Reifenwechsel
DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20200403T102000
DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20200403T113000
DTSTAMP;VALUE=DATE-TIME:20200326T165608Z
UID:TCK6EMQBQHQ8KB4PDQPT04Q7HBYNS2MEPZMO
SEQUENCE:0
LOCATION:Musterhausen
END:VEVENT
END:VCALENDAR

Results in:

Traceback (most recent call last):
  File "~/calreminder/calreminder.py", line 10, in <module>
    events += icalevents.icalevents.events(url=None, file=evtFile, string_content=None, fix_apple=True)
  File "~/.local/lib/python3.8/site-packages/icalevents/icalevents.py", line 50, in events
    found_events += parse_events(content, start=start, end=end)
  File "~/.local/lib/python3.8/site-packages/icalevents/icalparser.py", line 259, in parse_events
    timezones[name] = c.to_tz()
  File "~/.local/lib/python3.8/site-packages/icalendar/cal.py", line 650, in to_tz
    assert dst_offset is not False
AssertionError

As you can see, the file was generated by khal (some days ago...).

Event was on 03.04.2020 at 10:20 am to 11:30 am CEST (summer time). File/Event was created on 26.03.2020 at 4:30 pm CET (normal time).

Is it right to open here or must this be handled by icalevents? Its reproducible if the same statements are done directly with icalendar.

Thanks and best regards,
Lukas

niccokunzmann added a commit to niccokunzmann/icalendar that referenced this issue Aug 16, 2022
@niccokunzmann
Copy link
Member

@monofox, I created #379 and the tests are passing.
Did I understand it right that there should be an assertion failing when the file is read?
If that is so, we can merge #379 and say it is fixed in the latest version.
What are your thoughts on that?

@monofox
Copy link
Author

monofox commented Aug 17, 2022

It is failing with master branch with an AssertionError i do not expect. I would expect, that it is parseable.
And i still can reproduce:

#!/usr/bin/env python3
import icalendar

ics = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
DTSTART;VALUE=DATE-TIME:20200329T030000
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Reifenwechsel
DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20200403T102000
DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20200403T113000
DTSTAMP;VALUE=DATE-TIME:20200326T165608Z
UID:TCK6EMQBQHQ8KB4PDQPT04Q7HBYNS2MEPZMO
SEQUENCE:0
LOCATION:Musterhausen
END:VEVENT
END:VCALENDAR
"""
cal = icalendar.Calendar.from_ical(ics)
timezone = list(cal.walk())[1]
print(timezone)
pytz = timezone.to_tz()

According to the description - to_tz should "convert this VTIMEZONE component to a pytz.timezone object". Instead its throwing assert error.

Event was generated by khal.

niccokunzmann added a commit to niccokunzmann/icalendar that referenced this issue Aug 19, 2022
@niccokunzmann
Copy link
Member

Awesome! #379 can reproduce the error! PR for a fix to that branch is welcome!

@niccokunzmann niccokunzmann added the tested and needs fix This pull request tests code but needs a contribution to fix the test - TDD label Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested and needs fix This pull request tests code but needs a contribution to fix the test - TDD
Projects
None yet
Development

No branches or pull requests

2 participants