/** * Returns a description of the underlying formatters. * * @return string a description of this formatter, not null */ public function __toString() { $pattern = $this->printerParser->__toString(); $pattern = StringHelper::startsWith($pattern, "[") ? $pattern : substr($pattern, 1, strlen($pattern) - 2); return $pattern; // TODO: Fix tests to not depend on toString() // return "DateTimeFormatter[" + locale + // (chrono != null ? "," + chrono : "") + // (zone != null ? "," + zone : "") + // pattern + "]"; }
/** * Parses the ID, taking a flag to indicate whether {@code ZoneRulesException} * should be thrown or not, used in deserialization. * * TODO package visiblity * * @param string $zoneId the time-zone ID, not null * @param bool $checkAvailable whether to check if the zone ID is available * @return ZoneID the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws ZoneRulesException if checking availability and the ID cannot be found */ public static function _of($zoneId, $checkAvailable) { if (strlen($zoneId) <= 1 || StringHelper::startsWith("+", $zoneId) || StringHelper::startsWith("-", $zoneId)) { return ZoneOffset::of($zoneId); } else { if (StringHelper::startsWith("UTC", $zoneId) || StringHelper::startsWith("GMT", $zoneId)) { return self::ofWithPrefix($zoneId, 3, $checkAvailable); } else { if (StringHelper::startsWith("UT", $zoneId)) { return self::ofWithPrefix($zoneId, 2, $checkAvailable); } } } return ZoneRegion::ofId($zoneId, $checkAvailable); }