Skip to content

Timezone information is dropped when converting internally to UTC #188

@moccacup

Description

@moccacup

When opening a calendarfile (*.ics), the timezone will be replaced by utc.

This causes wrong times for recurrent events. For example you use a recurring event in Europe, every month from 10:00 to 11:00 (timezone europe/berlin). It is read resp. converted correctly for now (summer) in utc (8:00 to 9:00 utc).

But in the wintermonths the event will be at a wrong time. (8:00-9:00 utc is the 9:00-10:00 (timezone europe/berlin).

a complete examplefile:

import ics

ics_orig = """BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//SabreDAV//SabreDAV 3.2.2//EN
X-WR-CALNAME:test
X-APPLE-CALENDAR-COLOR:#FF9500
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
DTSTART:19810329T020000
TZNAME:MESZ
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
DTSTART:19961027T030000
TZNAME:MEZ
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20190801T112629Z
UID:DD5E3484-E37A-4A5B-AA5D-31B8394DBF7B
RRULE:FREQ=MONTHLY;INTERVAL=1
DTEND;TZID=Europe/Berlin:20190701T110000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:every month 10:00 to 11:00
DTSTART;TZID=Europe/Berlin:20190701T100000
DTSTAMP:20190801T113222Z
SEQUENCE:0
END:VEVENT
END:VCALENDAR"""

cal = ics.Calendar(ics_orig)
ics_back = str(cal)
print (ics_back)

the resulting calendarfile points out only:

BEGIN:VCALENDAR
X-WR-CALNAME:test
X-APPLE-CALENDAR-COLOR:#FF9500
PRODID:-//SabreDAV//SabreDAV 3.2.2//EN
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
CREATED:20190801T112629Z
RRULE:FREQ=MONTHLY;INTERVAL=1
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SEQUENCE:0
DTSTAMP:20190801T113222Z
DTSTART:20190701T080000Z
DTEND:20190701T090000Z
SUMMARY:every month 10:00 to 11:00
TRANSP:OPAQUE
UID:DD5E3484-E37A-4A5B-AA5D-31B8394DBF7B
END:VEVENT
END:VCALENDAR

so the original DTSTART ist changed from
DTSTART;TZID=Europe/Berlin:20190701T100000
to
DTSTART:20190701T080000Z
which is correct only for summer time = "daylight" time
but is different for "Standard" -time = winter time

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions