Commit ccc0e440 authored by Manfred Kutas's avatar Manfred Kutas

ZP-1224 Pass PHP supported timezone to DateTimeZone.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 0e4a1a39
...@@ -538,7 +538,7 @@ class BackendCalDAV extends BackendDiff { ...@@ -538,7 +538,7 @@ class BackendCalDAV extends BackendDiff {
$timezones = $ical->GetComponents("VTIMEZONE"); $timezones = $ical->GetComponents("VTIMEZONE");
$timezone = ""; $timezone = "";
if (count($timezones) > 0) { if (count($timezones) > 0) {
$timezone = TimezoneUtil::ParseTimezone($timezones[0]->GetPValue("TZID")); $timezone = TimezoneUtil::GetPhpSupportedTimezone($timezones[0]->GetPValue("TZID"));
} }
if (!$timezone) { if (!$timezone) {
$timezone = date_default_timezone_get(); $timezone = date_default_timezone_get();
...@@ -1449,6 +1449,7 @@ class BackendCalDAV extends BackendDiff { ...@@ -1449,6 +1449,7 @@ class BackendCalDAV extends BackendDiff {
* @throws Exception * @throws Exception
*/ */
private function _GetTimezoneString($timezone, $with_names = true) { private function _GetTimezoneString($timezone, $with_names = true) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV->_GetTimezoneString(): using '%s' timezone", $timezone));
// UTC needs special handling // UTC needs special handling
if ($timezone == "UTC") if ($timezone == "UTC")
return base64_encode(pack('la64vvvvvvvvla64vvvvvvvvl', 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0)); return base64_encode(pack('la64vvvvvvvvla64vvvvvvvvl', 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 0, 0, 0, 0));
......
...@@ -1359,4 +1359,23 @@ class TimezoneUtil { ...@@ -1359,4 +1359,23 @@ class TimezoneUtil {
} }
return self::getMSTZnameFromTZName(trim($timezone, '"')); return self::getMSTZnameFromTZName(trim($timezone, '"'));
} }
/**
* Returns a timezone supported by PHP for DateTimeZone constructor.
* @see http://php.net/manual/en/timezones.php
*
* @param string $timezone
*
* @access public
* @return string
*/
public static function GetPhpSupportedTimezone($timezone) {
if (in_array($timezone, DateTimeZone::listIdentifiers())) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("TimezoneUtil::GetPhpSupportedTimezone(): '%s' is a PHP supported timezone", $timezone));
return $timezone;
}
$dtz = date_default_timezone_get();
ZLog::Write(LOGLEVEL_DEBUG, sprintf("TimezoneUtil::GetPhpSupportedTimezone(): '%s' is not a PHP supported timezone. Returning default timezone: '%s'", $timezone, $dtz));
return $dtz;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment