src/TimeZoneOffset.php
public static function of(int $hours, int $minutes = 0, int $seconds = 0) : TimeZoneOffset
    {
        Field\TimeZoneOffsetHour::check($hours);
        Field\TimeZoneOffsetMinute::check($minutes);
        Field\TimeZoneOffsetSecond::check($seconds);

        $err = ($hours > 0 && ($minutes < 0 || $seconds < 0))
            || ($hours < 0 && ($minutes > 0 || $seconds > 0))
            || ($minutes > 0 && $seconds < 0)
            || ($minutes < 0 && $seconds > 0);

        if ($err) {
            throw new DateTimeException('Time zone offset hours, minutes and seconds must have the same sign');
        }

        $totalSeconds = $hours * LocalTime::SECONDS_PER_HOUR
            + $minutes * LocalTime::SECONDS_PER_MINUTE
            + $seconds;

        Field\TimeZoneOffsetTotalSeconds::check($totalSeconds);

        return new TimeZoneOffset($totalSeconds);
    }
public static function of(int $hours, int $minutes = 0, int $seconds = 0) : TimeZoneOffset
    {
        Field\TimeZoneOffsetHour::check($hours);
        Field\TimeZoneOffsetMinute::check($minutes);
        Field\TimeZoneOffsetSecond::check($seconds);

        $err = ($hours > 0 && ($minutes < 0 || $seconds < 0))
            || ($hours < 0 && ($minutes > 0 || $seconds > 0))
            || ($minutes > 0 && $seconds < 0)
            || ($minutes < 0 && $seconds > 0);

        if ($err) {
            throw new DateTimeException('Time zone offset hours, minutes and seconds must have the same sign');
        }

        $totalSeconds = $hours * LocalTime::SECONDS_PER_HOUR
            + $minutes * LocalTime::SECONDS_PER_MINUTE
            + $seconds;

        Field\TimeZoneOffsetTotalSeconds::check($totalSeconds);

        return new TimeZoneOffset($totalSeconds);
    }
public static function of ( int $ hours , int $ minutes = 0 , int $ seconds = 0 ) : TimeZoneOffset { Field \ TimeZoneOffsetHour :: check ( $ hours ) ; Field \ TimeZoneOffsetMinute :: check ( $ minutes ) ; Field \ TimeZoneOffsetSecond :: check ( $ seconds ) ; $ err = ( $ hours > 0 && ( $ minutes < 0 || $ seconds < 0 ) ) || ( $ hours < 0 && ( $ minutes > 0 || $ seconds > 0 ) ) || ( $ minutes > 0 && $ seconds < 0 ) || ( $ minutes < 0 && $ seconds > 0 ) ; if ( $ err ) { throw new DateTimeException ( 'Time zone offset hours, minutes and seconds must have the same sign' ) ; } $ totalSeconds = $ hours * LocalTime :: SECONDS_PER_HOUR + $ minutes * LocalTime :: SECONDS_PER_MINUTE + $ seconds ; Field \ TimeZoneOffsetTotalSeconds :: check ( $ totalSeconds ) ; return new TimeZoneOffset ( $ totalSeconds ) ; }
Obtains an instance of `TimeZoneOffset` using an offset in hours, minutes and seconds.

The total number of seconds must not exceed 64,800 seconds.

@param int $hours   The time-zone offset in hours.
@param int $minutes The time-zone offset in minutes, from 0 to 59, sign matching hours.
@param int $seconds The time-zone offset in seconds, from 0 to 59, sign matching hours and minute.

@return TimeZoneOffset

@throws DateTimeException If the values are not in range or the signs don't match.
Obtains an instance of TimeZoneOffset using an offset in hours minutes and seconds .