本文整理汇总了PHP中Horde_Date::getTimezoneAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Date::getTimezoneAlias方法的具体用法?PHP Horde_Date::getTimezoneAlias怎么用?PHP Horde_Date::getTimezoneAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Date
的用法示例。
在下文中一共展示了Horde_Date::getTimezoneAlias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTimezone
/**
* Attempt to guess the timezone identifier from the $offsets array.
*
* Since it's impossible to know exactly which olson timezone name a
* specific set of offsets represent (multiple timezone names may be
* described by the same offsets for any given year) we allow passing an
* expected timezone. If this matches one of the timezones that matches the
* offsets, we return that. Otherwise, we attempt to get the full timezone
* name from Horde_Date and if that fails, return the abbreviated timezone
* name of the first timezone that matches the provided offsets.
*
* @param array|string $offsets The timezone to check. Either an array
* of offsets or an activesynz tz blob.
* @param string $expectedTimezone The expected timezone. If not empty, and
* present in the results, will return.
*
* @return string The timezone identifier.
*/
public function getTimezone($offsets, $expectedTimezone = null)
{
$timezones = $this->getListOfTimezones($offsets, $expectedTimezone);
if (isset($timezones[$expectedTimezone])) {
return $expectedTimezone;
} else {
return Horde_Date::getTimezoneAlias(current($timezones));
}
}
示例2: testGetTimezoneAlias
public function testGetTimezoneAlias()
{
$this->assertEquals('Europe/Berlin', Horde_Date::getTimezoneAlias('W. Europe Standard Time'));
$this->assertEquals('Europe/Berlin', Horde_Date::getTimezoneAlias('W. Europe'));
$this->assertEquals('Europe/Berlin', Horde_Date::getTimezoneAlias('CET'));
$this->assertEquals('UTC', Horde_Date::getTimezoneAlias('UTC'));
}
示例3: getZone
/**
* Returns an object representing an invidual timezone.
*
* Maps to a "Zone" entry in the timezone database. Works with
* zone aliases and other common timezone names too.
*
* @param string $zone A timezone name.
*
* @return Horde_Timezone_Zone A timezone object.
*/
public function getZone($zone)
{
if (!$this->_zones) {
$this->_extractAndParse();
}
$zone = Horde_Date::getTimezoneAlias($zone);
$alias = isset($this->_links[$zone]) ? $this->_links[$zone] : $zone;
if (!isset($this->_zones[$alias])) {
throw new Horde_Timezone_Exception(sprintf('Timezone %s not found', $zone));
}
$this->_zones[$alias]->setTzid($zone);
return $this->_zones[$alias];
}