/** * Creates a new timezone instance for the given identifier. * * Please note that this method caches the results for each identifier, so * if you plan to modify the timezones returned by this method you need to * clone them first. Alternatively you can set the cache parameter to false, * but this will mean the data for this timezone will be loaded from the * hdd again. * * @return AgaviTimeZone The timezone instance for the given id. * * @author Dominik del Bondio <*****@*****.**> * @since 0.11.0 */ public function createTimeZone($id, $cache = true) { if (!isset($this->timeZoneList[$id])) { try { return AgaviTimeZone::createCustomTimeZone($this, $id); } catch (Exception $e) { return null; } } if (!isset($this->timeZoneCache[$id]) || !$cache) { $currId = $id; // resolve links while ($this->timeZoneList[$currId]['type'] == 'link') { $currId = $this->timeZoneList[$currId]['to']; } $zoneData = (include AgaviConfig::get('core.cldr_dir') . '/timezones/' . $this->timeZoneList[$currId]['filename']); $zone = new AgaviOlsonTimeZone($this, $id, $zoneData); $zone->setResolvedId($currId); if ($cache) { $this->timeZoneCache[$id] = $zone; } } else { $zone = $this->timeZoneCache[$id]; } return $zone; }
/** * @expectedException InvalidArgumentException */ public function testTicket958() { $tm = $this->getContext()->getTranslationManager(); $tz = AgaviTimeZone::createCustomTimeZone($tm, '+01:00'); }