getTimezoneAlias() public static méthode

We currently support Windows and Lotus timezone names, and timezone abbreviations.
public static getTimezoneAlias ( string $timezone ) : string
$timezone string Some timezone alias.
Résultat string The Olson timezone name, or the original value, if no alias found.
Exemple #1
0
 /**
  * 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));
     }
 }
Exemple #2
0
 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'));
 }
Exemple #3
0
 /**
  * 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];
 }