/** * TODO performance * * @param string $text * @param ParsePosition $ppos * @param bool $isCaseSensitive * @return null|string */ private function match($text, ParsePosition $ppos, $isCaseSensitive) { $ids = ZoneId::getAvailableZoneIds(); if (!$isCaseSensitive) { $ids = \array_map('\\strtolower', $ids); $text = \strtolower($text); } $ids = \array_flip($ids); $pos = $ppos->getIndex(); $max = \strlen($text) - 1; for ($i = $max; $i >= $pos; $i--) { $str = \substr($text, $pos, $i - $pos + 1); if (isset($ids[$str])) { $ppos->setIndex($i + 1); return ZoneId::getAvailableZoneIds()[$ids[$str]]; } } return null; }
public function test_adjustInto_ZonedDateTime() { $base = ZoneOffset::ofHoursMinutesSeconds(1, 1, 1); foreach (ZoneId::getAvailableZoneIds() as $zoneId) { //Do not change $offset of ZonedDateTime after adjustInto() $zonedDateTime_target = ZonedDateTime::ofDateAndTime(LocalDate::of(1909, 2, 2), LocalTime::of(10, 10, 10), ZoneId::of($zoneId)); $zonedDateTime_result = $base->adjustInto($zonedDateTime_target); $this->assertEquals($zonedDateTime_target->getOffset(), $zonedDateTime_result->getOffset()); $offsetDateTime_target = $zonedDateTime_target->toOffsetDateTime(); $offsetDateTime_result = $base->adjustInto($offsetDateTime_target); $this->assertEquals($base, $offsetDateTime_result->getOffset()); } }
public function test_getAvailableGroupIds() { $zoneIds = ZoneId::getAvailableZoneIds(); $this->assertContains("Europe/London", $zoneIds); }