예제 #1
0
 private function make(ZoneOffset $offset)
 {
     return $offset->getRules();
 }
예제 #2
0
 /**
  * Obtains an instance of {@code ZoneId} wrapping an offset.
  * <p>
  * If the prefix is "GMT", "UTC", or "UT" a {@code ZoneId}
  * with the prefix and the non-zero offset is returned.
  * If the prefix is empty {@code ""} the {@code ZoneOffset} is returned.
  *
  * @param string $prefix the time-zone ID, not null
  * @param ZoneOffset $offset the offset, not null
  * @return ZoneId the zone ID, not null
  * @throws IllegalArgumentException if the prefix is not one of
  *     "GMT", "UTC", or "UT", or ""
  */
 public static function ofOffset($prefix, ZoneOffset $offset)
 {
     if (!is_string($prefix)) {
         throw new \InvalidArgumentException();
     }
     if (strlen($prefix) === 0) {
         return $offset;
     }
     if ($prefix !== "GMT" && $prefix !== "UTC" && $prefix !== "UT") {
         throw new IllegalArgumentException("prefix should be GMT, UTC or UT, is: " . $prefix);
     }
     if ($offset->getTotalSeconds() !== 0) {
         $prefix .= $offset->getId();
     }
     return new ZoneRegion($prefix, $offset->getRules());
 }