Wednesday, May 22, 2013

Fixing ICS Time Zone

I was getting my agenda setup for the upcoming 2013 Apereo conference in San Diego and was excited to see their scheduling app let you select presentations and export a .ics file. Yay, something easy to import into Google Calendar and I'll have my whole schedule right on my phone!

Well, that was the case until I imported the events and had no attached time-zone information ... boo!

So here is the quick-and-dirty hack to add time-zone information to your .ics file.

Add a VTIMEZONE Block

These go right above the first BEGIN:VEVENT block in your ics file. You only need to add time-zone definitions for the time zones you want to reference in your events. At the bottom of the post are more timezone blocks
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

Update DTSTART and DTEND

For each VEVENT you want to set a timezone for update the DTSTART and DTEND to include a timezone reference.
Before:
DTSTART:20130602T130000
DTEND:20130602T160000
After:
DTSTART;TZID=America/Los_Angeles:20130602T130000
DTEND;TZID=America/Los_Angeles:20130602T160000

US VTIMEZONE List

Below are VTIMEZONE blocks for: Pacific, Mountain, Mountain - Arizona, Central, and Eastern time zones.

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:VTIMEZONE
TZID:America/Phoenix
X-LIC-LOCATION:America/Phoenix
BEGIN:STANDARD
TZOFFSETFROM:-0700
TZOFFSETTO:-0700
TZNAME:MST
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:America/Chicago
X-LIC-LOCATION:America/Chicago
BEGIN:DAYLIGHT
TZOFFSETFROM:-0600
TZOFFSETTO:-0500
TZNAME:CDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0500
TZOFFSETTO:-0600
TZNAME:CST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE

1 comment:

Tim Levett said...

Helpful tip for vim and replacing every DTSTART/DTEND:

%s/DTSTART:/DTSTART;TZID=America\/Los_Angeles:/g

:%s/DTEND:/DTEND;TZID=America\/Los_Angeles:/g