public function testUtc() { $this->assertTimeZoneOffsetIs(0, TimeZoneOffset::utc()); }
/** * @return TimeZoneOffset */ public static function utc() { return TimeZoneOffset::utc(); }
/** * @param DateTimeParseResult $result * * @return TimeZoneOffset * * @throws DateTimeException If the offset is not valid. * @throws DateTimeParseException If required fields are missing from the result. */ public static function from(DateTimeParseResult $result) { $sign = $result->getField(Field\TimeZoneOffsetSign::NAME); if ($sign === 'Z' || $sign === 'z') { return TimeZoneOffset::utc(); } $hour = $result->getField(Field\TimeZoneOffsetHour::NAME); $minute = $result->getField(Field\TimeZoneOffsetMinute::NAME); $second = $result->getOptionalField(Field\TimeZoneOffsetSecond::NAME); $hour = (int) $hour; $minute = (int) $minute; $second = (int) $second; if ($sign === '-') { $hour = -$hour; $minute = -$minute; $second = -$second; } return self::of($hour, $minute, $second); }