Wrong Time When Importing ICS Event

2019-08-26 20:53发布

问题:

I have a .ics file that has the following iCalendar code:

BEGIN:VCALENDAR

PRODID;X-RICAL-TZSOURCE=TZINFO:-//Company Name//NONSGML example.co
 m//EN
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:PUBLISH

BEGIN:VTIMEZONE
TZID;X-RICAL-TZSOURCE=TZINFO:America/Los_Angeles
BEGIN:DAYLIGHT
DTSTART:20180311T020000
RDATE:20180311T020000
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
END:DAYLIGHT
END:VTIMEZONE

BEGIN:VEVENT
CREATED;VALUE=DATE-TIME:20180622T002920Z
DTEND;TZID=America/Los_Angeles;VALUE=DATE-TIME:20180703T173000
DTSTART;TZID=America/Los_Angeles;VALUE=DATE-TIME:20180703T170000
DTSTAMP;VALUE=DATE-TIME:20180622T002920Z
ATTENDEE#<Client 1234 "Lorem Ipsum">
UID:id@example.com
DESCRIPTION:Super Secret Event
URL:https://example.com/path/id
SUMMARY:Super secret summary
ORGANIZER;CN=Tamer Shlash;CUTYPE=INDIVIDUAL;PARTSTAT=A
 CCEPTED:mailto:noreply@example.com
SEQUENCE:0
END:VEVENT

END:VCALENDAR

However, when I download the file on an Android device and import it, the event is off by 1 hour. Trying on a Mac or iPhone device will import the event with the correct time.

Any idea why I'm getting this weird behaviour on Android?

回答1:

Your VTIMEZONE definition for America/Los Angeles is bogus. It is missing a STANDARD component. To see what it should look like, just invite yourself to a meeting from any client and look at the resulting ics file.

Things are working on Mac/iOS because those clients tend to ignore the actual definition and just rely on the TZID=America/Los_Angeles to map it to their own definition.