Example #1
0
 public function testUtc()
 {
     $this->assertTimeZoneOffsetIs(0, TimeZoneOffset::utc());
 }
Example #2
0
 /**
  * @return TimeZoneOffset
  */
 public static function utc()
 {
     return TimeZoneOffset::utc();
 }
Example #3
0
 /**
  * @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);
 }