How to Specify Timezone in ics File which will work efficiently with google,outlook and apple?

a 夏天 提交于 2020-03-21 11:41:58

问题


I want to generate an ics file which will be compatible with google, outlook and apple calendars. I am able to do it fine, but the problem is that I can't specify timezone block in file which will be compatible for above mentioned apps. I currently used X-Wr-timezone property which doesn't work with outlook and gives different time in google. I need the solution for this problem. My ics file:

BEGIN:VCALENDA
RPRODID:-//sample//sam Calendar//EN
VERSION:2.0
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
X-WR-TIMEZONE:America/Los_Angeles
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART;TZID=America/Los_Angeles:20160206T074400
DTEND;TZID=America/Los_Angeles:20160206T084400
DESCRIPTION:Your appointment Details:\n\nPatient Details:Kou Kul\nKeven\n\nAppointment Type:Counselling (30 min)\n\nThanks.
LOCATION: Pune
SEQUENCE:0
PRIORITY:5
STATUS:CONFIRMED
SUMMARY:Appointment Details:- John Bond
UID:X:201600U2800000A9Yp0EAF@sample
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

回答1:


use the VTIMEZONE component before the VEVENT: https://tools.ietf.org/html/rfc5545#section-3.6.5

   BEGIN:VTIMEZONE
   TZID:America/New_York
   LAST-MODIFIED:20050809T050000Z
   BEGIN:STANDARD
   DTSTART:20071104T020000
   TZOFFSETFROM:-0400
   TZOFFSETTO:-0500
   TZNAME:EST
   END:STANDARD
   BEGIN:DAYLIGHT
   DTSTART:20070311T020000
   TZOFFSETFROM:-0500
   TZOFFSETTO:-0400
   TZNAME:EDT
   END:DAYLIGHT
   END:VTIMEZONE

So the final assembled ICS file would look like this (based on the OP's ICS file; N.B. on his 1st line the "R" of VCALENDAR was pushed to the beginning of "PRODID" on the second line, I have corrected it in the answer):

BEGIN:VCALENDAR
PRODID:-//sample//sam Calendar//EN
VERSION:2.0
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
X-WR-TIMEZONE:America/Los_Angeles
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:America/New_York
LAST-MODIFIED:20050809T050000Z
BEGIN:STANDARD
DTSTART:20071104T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTART:20160206T074400
DTEND:20160206T084400
DESCRIPTION:Your appointment Details:\n\nPatient Details:Kou Kul\nKeven\n\nAppointment Type:Counselling (30 min)\n\nThanks.
LOCATION: Pune
SEQUENCE:0
PRIORITY:5
STATUS:CONFIRMED
SUMMARY:Appointment Details:- John Bond
UID:X:201600U2800000A9Yp0EAF@sample
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

I have not tested this specific ICS, so cannot predict the behaviour of using both VTIMEZONE with X-WR-TIMEZONE.

Another point of subtlety is that the Date/Time format cannot include a timezone. So for example if you were to build this in PHP, you'd want to make sure that:

const DT_FORMAT = 'Ymd\THis';

e.g. DTSTART:20160206T074400

and NOT:

const DT_FORMAT = 'Ymd\THis\Z';

e.g. DTSTART:20160206T074400Z

This Date/Time format is important for the Date/Times in the VEVENT block. I have had success when there was a "Z" at the end of the "LAST_MODIFIED" field.

On a sidenote, the OP was working in the Los Angeles timezone, but this answer shows New York information in the VTIMEZONE block. The appropriate information for Los Angeles would have to be calculated (e.g. daylight savings offset, etc...)

Final observation, new line "\n" doesn't work with google calendar as of April 2018. iCal obeys it as long as "VERSION:2.0" is used.




回答2:


Suppose the questioner lives in Los Angeles and uses Latest US-EN version OUTLOOK. I don't know why specify time zone in New York. Los Angles is PDT or PST Timezone(written in Japanese) I find Important Point how to specify timezone on ics file, set 5 Items same value

  1. X-WR-TIMEZONE:America/Los_Angeles
  2. TZID:America/Los_Angeles
  3. X-LIC-LOCATION:America/Los_Angeles
  4. DTSTART;TZID="America/Los_Angeles"
  5. DTEND;TZID="America/Los_Angeles"

According to this sight Summer time (daylight saving time - DST ) is recurrent. So, should add RRULE a.k.a Rcurrent rule. Of course, previous code works, well. Still, even if In September 2019, New Line \n ( means carriage return or/and line feed ) is still valid for Google Calender on Andoroid Smartphones. And following Item is not so need

  • UID:
  • SEQUENCE:0 Befor You use Sequence, Delete added item in scheduler.

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 19.0 MIMEDIR//EN
VERSION:2.0
X-WR-TIMEZONE:America/Los_Angeles
METHOD:PUBLISH
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
SUMMARY:Appointment
LOCATION:Pune
DESCRIPTION:Your appointment Details:\n\nPatient Details:Kou Kul\nKeven\n\nAppointment Type:Counselling (30 min)\n\nThanks.
DTSTART;TZID="America/Los_Angeles":20160206T074400
DTEND;TZID="America/Los_Angeles":20160206T084400
PRIORITY:5
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR


来源:https://stackoverflow.com/questions/35645402/how-to-specify-timezone-in-ics-file-which-will-work-efficiently-with-google-outl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!