Update of /cvsroot/phpicalendar/phpicalendar/functions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25617/phpicalendar/functions
Modified Files:
date_functions.php ical_parser.php
Log Message:
create new date function parse_tz to deal with mozilla and other tzids. Apply to ical_parser
Index: date_functions.php
===================================================================
RCS file: /cvsroot/phpicalendar/phpicalendar/functions/date_functions.php,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** date_functions.php 5 Apr 2006 04:43:59 -0000 1.35
--- date_functions.php 12 Nov 2006 07:34:34 -0000 1.36
***************
*** 288,290 ****
--- 288,303 ----
return array($unixtime, $date, $time, $allday);
}
+
+ //TZIDs in calendars often contain leading information that should be stripped
+ //Example: TZID=/mozilla.org/20050126_1/Europe/Berlin
+ //Need to return the last part only
+ function parse_tz($data){
+ $fields = explode("/",$data);
+ $tz = array_pop($fields);
+ $tmp = array_pop($fields);
+ if (isset($tmp) && $tmp != "") $tz = "$tmp/$tz";
+ return $tz;
+ }
+
+
?>
Index: ical_parser.php
===================================================================
RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v
retrieving revision 1.215
retrieving revision 1.216
diff -C2 -d -r1.215 -r1.216
*** ical_parser.php 2 Nov 2006 08:06:03 -0000 1.215
--- ical_parser.php 12 Nov 2006 07:34:34 -0000 1.216
***************
*** 1074,1078 ****
// do nothing
} elseif ($eachval[0] == 'TZID') {
! $recurrence_id['tzid'] = $eachval[1];
} elseif ($eachval[0] == 'RANGE') {
$recurrence_id['range'] = $eachval[1];
--- 1074,1078 ----
// do nothing
} elseif ($eachval[0] == 'TZID') {
! $recurrence_id['tzid'] = parse_tz($eachval[1]);
} elseif ($eachval[0] == 'RANGE') {
$recurrence_id['range'] = $eachval[1];
***************
*** 1120,1124 ****
break;
case 'X-WR-TIMEZONE':
! $calendar_tz = $data;
$master_array['calendar_tz'] = $calendar_tz;
break;
--- 1120,1124 ----
break;
case 'X-WR-TIMEZONE':
! $calendar_tz = parse_tz($data);
$master_array['calendar_tz'] = $calendar_tz;
break;
|