modolabs / Kurogo-Mobile-Web

Kurogo is a PHP framework for delivering high quality, data driven customizable content to a wide range of mobile devices. Its strengths lie in the customizable system that allows you to adapt content from a variety of sources and easily present that to mobile devices from feature phones, to early generation smart phones, to modern devices and tablets
http://kurogo.org
GNU Lesser General Public License v2.1
198 stars 99 forks source link

ICalendar does not accept valid TZID values #32

Closed eebs closed 12 years ago

eebs commented 12 years ago

Note The feed we are working with fixed the timezone to be 'America/New_York, so it is not currently representative of the issue. However, the code shown below illustrates the problem.

We're working with a new ical feed (http://uvmbored.com/event/?feed=ical) and it's throwing some errors. It contains a TZID value that looks like this:

DTSTAMP;TZID=US-Eastern:20110928T110000

This is a valid value for TZID as described in RFC2445 on Page 30. Line 356 in ICalendar.php takes the TZID value and passes it to a new DateTimeZone object:

$datetime = new DateTime($value, new DateTimeZone($params['TZID']));

The DateTimeZone constructor takes a timezone as a parameter. However, I can't find the exact string 'US-Eastern' in the list of supported timezones. The closest I can find is listed under 'Others' (all timezones listed under Others except UTC are deprecated) and is the string 'US/Eastern'.

The error Kurogo is giving me is as follows:

DateTimeZone::__construct(): Unknown or bad timezone (US-Eastern)
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (US-    Eastern)' in /users/w/e/webmster/mobile-dev.uvm.edu/uvm-kurogo/lib/Calendar/ICalendar.php:356

Is this just a problem between the two standards?

Thanks, Eebs

eebs commented 12 years ago

I'm going to close this issue for now, as it has been fixed by 2d828205. While it is still not technically accepting of valid iCal timezones, the code handles the issue much better now.

accommodate unusual timezone values more gracefully fixes #32.

chungyuanyang commented 11 years ago

You should not change your code to create a timezone using "US-Eastern" since this TZID is only valid in that iCalendar object. On the same page of RFC2445 (page 30), there is a paragraph saying: "An individual "VTIMEZONE" calendar component MUST be specified for each unique "TZID" parameter value specified in the iCalendar object." Therefore, the TZID "US-Eastern" refers to a VTIMEZONE component of the iCalendar object. You should be able to find the VTIMEZONE component in the iCalendar file like: BEGIN:VTIMEZONE TZID:US-Eastern LAST-MODIFIED:19870101T000000Z TZURL:http://zones.stds_r_us.net/tz/US-Eastern BEGIN:STANDARD DTSTART:19671029T020000 RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 TZOFFSETFROM:-0400 TZOFFSETTO:-0500 TZNAME:EST END:STANDARD BEGIN:DAYLIGHT DTSTART:19870405T020000 RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 TZOFFSETFROM:-0500 TZOFFSETTO:-0400 TZNAME:EDT END:DAYLIGHT END:VTIMEZONE