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

VObject creates invalid .ics files when using AST timezone #175

Open
derelk opened this issue Dec 1, 2021 · 1 comment
Open

VObject creates invalid .ics files when using AST timezone #175

derelk opened this issue Dec 1, 2021 · 1 comment

Comments

@derelk
Copy link

derelk commented Dec 1, 2021

The following sample code to generate a simple event that spans 2 timezones (AST to EST) seems to create an invalid .ics file. The file cannot be read correctly by the macOS Calendar app, which treats it as a calendar rather than an individual event and will not import the event regardless.

It's also possible that it's an Apple bug, rather than vobject, but I don't understand the VCalendar format well enough to know where the issue is. My guess is it for some reason thinks the end time is before the start time due to the timezone difference, but that isn't true; these timezones are only 1 hour apart for this date, and I even used an assert to confirm that the end time is greater than the start time. Still, if I make the times further apart, it works correctly.

Any idea what's going on here?

macOS Big Sur 11.6.1
Calendar 11.0
Python 3.9.9
vobject 0.9.6.1

from datetime import datetime
from dateutil import zoneinfo

import vobject


if __name__ == '__main__':
    start = datetime(2021, 12, 1, 15, 30, tzinfo=zoneinfo.gettz('America/St_Thomas'))
    end = datetime(2021, 12, 1, 18, 30, tzinfo=zoneinfo.gettz('America/New_York'))
    assert end > start

    cal = vobject.iCalendar()
    event = cal.add('vevent')
    event.add('summary').value = 'Test Event'
    event.add('dtstart').value = start
    event.add('dtend').value = end

    with open('test.ics', 'w') as f:
        cal.serialize(f)
@derelk
Copy link
Author

derelk commented Dec 6, 2021

I've learned that if I replace the TZID in DTSTART and DTEND with the timezone name, the .ics file works as expected.

Before (doesn't work):

DTSTART;TZID=AST:20211201T153000
DTEND;TZID=EST:20211201T183000

After (works):

DTSTART;TZID=America/Anguilla:20211201T153000
DTEND;TZID=US/Eastern:20211201T183000

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

No branches or pull requests

1 participant