Skip to content

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

@derekspelledcorrectly

Description

@derekspelledcorrectly

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions