diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index d9ee350c7e..c2ef533067 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -752,7 +752,7 @@ class calendar_ical extends calendar_boupdate static $timezone_tzid; if (is_null($timezone) || $timezone_tzid != $tzid) { - $timezone = new DateTimeZone($timezone_tzid = $tzid); + $timezone = calendar_timezones::DateTimeZone($timezone_tzid = $tzid); } $time->setTimezone($timezone); $params['TZID'] = $tzid; @@ -1507,7 +1507,7 @@ class calendar_ical extends calendar_boupdate { try { - $tz = new DateTimeZone($attributes['params']['TZID']); + $tz = calendar_timezones::DateTimeZone($attributes['params']['TZID']); $event['tzid'] = $tz->getName(); } catch(Exception $e) diff --git a/calendar/inc/class.calendar_timezones.inc.php b/calendar/inc/class.calendar_timezones.inc.php index f84938d74b..71edefac5d 100644 --- a/calendar/inc/class.calendar_timezones.inc.php +++ b/calendar/inc/class.calendar_timezones.inc.php @@ -55,6 +55,24 @@ class calendar_timezones */ protected static $tz2id = array(); + /** + * Get DateTimeZone object for a given TZID + * + * We use our database to replace eg. Windows timezones not understood by PHP with their standard TZID + * + * @param string $tzid + * @return DateTimeZone + * @throws Exception if called with an unknown TZID + */ + public function DateTimeZone($tzid) + { + if (($id = self::tz2id($tzid,'alias'))) + { + $tzid = self::id2tz($id); + } + return new DateTimeZone($tzid); + } + /** * Get the nummeric id (or other data) for a given TZID * @@ -242,6 +260,36 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_ echo '
\n\$no_vtimezone = array(\n\t'".implode("',\n\t'",$not_found)."',\n);\n\n"; + + echo "