Changeset View
Changeset View
Standalone View
Standalone View
lib/kolab_sync_timezone_converter.php
Show First 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | public function encodeTimezone($_timezone, $_startDate = null) | ||||
} | } | ||||
} | } | ||||
$offsets = $this->getOffsetsForTimezone($_timezone, $_startDate); | $offsets = $this->getOffsetsForTimezone($_timezone, $_startDate); | ||||
return $this->_packTimezoneInfo($offsets); | return $this->_packTimezoneInfo($offsets); | ||||
} | } | ||||
/** | |||||
* Returns an encoded timezone representation from $date | |||||
* | |||||
* @param DateTime $date The date with the timezone to encode | |||||
* | |||||
* @return string encoded timezone | |||||
*/ | |||||
public static function encodeTimezoneFromDate($date) | |||||
{ | |||||
if ($date instanceof DateTime) { | |||||
$timezone = $date->getTimezone(); | |||||
if ($timezone && ($tz_name = $timezone->getName()) != 'UTC') { | |||||
$tzc = self::getInstance(); | |||||
if ($tz_name = $tzc->encodeTimezone($tz_name, $date->format('Y-m-d'))) { | |||||
return $tz_name; | |||||
} | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
/** | /** | ||||
* Get offsets for given timezone | * Get offsets for given timezone | ||||
* | * | ||||
* @param string $_timezone Timezone identifier | * @param string $_timezone Timezone identifier | ||||
* @param string|int $_startDate Start date | * @param string|int $_startDate Start date | ||||
* | * | ||||
* @return array Timezone offsets | * @return array Timezone offsets | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines |