From c243d4aafdaea7617b2be768fa34bfb7e50714eb Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Sun, 12 Nov 2006 07:34:34 +0000 Subject: create new date function parse_tz to deal with mozilla and other tzids. Apply to ical_parser --- functions/date_functions.php | 13 +++++++++++++ functions/ical_parser.php | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'functions') diff --git a/functions/date_functions.php b/functions/date_functions.php index c6901d0..9c9bc30 100644 --- a/functions/date_functions.php +++ b/functions/date_functions.php @@ -287,4 +287,17 @@ function extractDateTime($data, $property, $field) { // Return the results. 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; +} + + ?> diff --git a/functions/ical_parser.php b/functions/ical_parser.php index b754d75..56475b2 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -1073,7 +1073,7 @@ foreach ($cal_filelist as $cal_key=>$filename) { if ($eachval[0] == 'RECURRENCE-ID') { // do nothing } elseif ($eachval[0] == 'TZID') { - $recurrence_id['tzid'] = $eachval[1]; + $recurrence_id['tzid'] = parse_tz($eachval[1]); } elseif ($eachval[0] == 'RANGE') { $recurrence_id['range'] = $eachval[1]; } elseif ($eachval[0] == 'VALUE') { @@ -1119,7 +1119,7 @@ foreach ($cal_filelist as $cal_key=>$filename) { $cal_displaynames[$cal_key] = $actual_calname; #correct the default calname based on filename break; case 'X-WR-TIMEZONE': - $calendar_tz = $data; + $calendar_tz = parse_tz($data); $master_array['calendar_tz'] = $calendar_tz; break; case 'DURATION': -- cgit v1.2.3