导入Google或Outlook时,ICS时区无法正确转换

时间:2019-07-09 13:50:49

标签: outlook google-calendar-api icalendar

我已经生成了ICS文件,该文件的事件分别在 9AM 开始并在太平洋时间(UTC-8) 5PM 结束。转换为我的本地时间(GMT + 4)时,它应显示事件为 10PM-6 AM ,而不是Google和Outlook都将其转换为 8PM-4 AM

我已经尝试针对日光和标准设置调整 TZOFFSETFROM TZOFFSETTO 设置,以显示正确的转换,但是它仅对Outlook有效-Google日历似乎可以完全忽略这些设置。但是,无论如何更改Outlook的设置似乎对我来说是错误的,因为最初它们具有适用于太平洋时间的正确设置?

随附了ICS文件的代码。

VERSION:2.0
PRODID:-//Foobar Corporation//NONSGML Foobar//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:EnergyPlex
X-WR-TIMEZONE:America/Los_Angeles
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:20190709T133817-12030501-example.com
DTSTAMP:20190709T133817
DTSTART;TZID=America/Los_Angeles:20190722T090000
DTEND;TZID=America/Los_Angeles:20190722T170000
SUMMARY:Energyplex Day Camp for Jenny Doe
DESCRIPTION: Your child is booked for a camp on this day.
END:VEVENT
BEGIN:VEVENT
UID:20190709T133817-422290764-example.com
DTSTAMP:20190709T133817
DTSTART;TZID=America/Los_Angeles:20190723T090000
DTEND;TZID=America/Los_Angeles:20190723T170000
SUMMARY:Energyplex Day Camp for Jenny Doe
DESCRIPTION: Your child is booked for a camp on this day.
END:VEVENT
BEGIN:VEVENT
UID:20190709T133817-847881910-example.com
DTSTAMP:20190709T133817
DTSTART;TZID=America/Los_Angeles:20190724T090000
DTEND;TZID=America/Los_Angeles:20190724T170000
SUMMARY:Energyplex Day Camp for Jenny Doe
DESCRIPTION: Your child is booked for a camp on this day.
END:VEVENT
BEGIN:VEVENT
UID:20190709T133817-1093239879-example.com
DTSTAMP:20190709T133817
DTSTART;TZID=America/Los_Angeles:20190725T090000
DTEND;TZID=America/Los_Angeles:20190725T170000
SUMMARY:Energyplex Day Camp for Jenny Doe
DESCRIPTION: Your child is booked for a camp on this day.
END:VEVENT
BEGIN:VEVENT
UID:20190709T133817-190860610-example.com
DTSTAMP:20190709T133817
DTSTART;TZID=America/Los_Angeles:20190726T090000
DTEND;TZID=America/Los_Angeles:20190726T170000
SUMMARY:Energyplex Day Camp for Jenny Doe
DESCRIPTION: Your child is booked for a camp on this day.
END:VEVENT
END:VCALENDAR

预期结果是在Outlook和Google日历上的格林尼治标准时间+4时区显示事件为晚上10点-上午6点

1 个答案:

答案 0 :(得分:1)

根据您提供的信息,您的假设是错误的。两者都显示正确的时间:

给出事件的开始和结束日期(例如,第一个事件的开始= 20190722T090000),America / Los_Angeles在该日期处于夏令时,因此在UTC-7。

20190722T090000 + 7h = 20190722T160000(UTC时间),转换为UTC + 4时,您将获得20190722T160000 + 4h = 20190722T200000,因此本地时间是晚上8点。