public function toSpec(\DateInterval $interval = null)
    {
        if ((null === $interval) && isset($this)) {
            $interval = $this;
        }

        $string = 'P';

        foreach (self::$date as $property => $suffix) {
            if ($interval->{$property}) {
                $string .= $interval->{$property} . $suffix;
            }
        }

        if ($interval->h || $interval->i || $interval->s) {
            $string .= 'T';

            foreach (self::$time as $property => $suffix) {
                if ($interval->{$property}) {
                    $string .= $interval->{$property} . $suffix;
                }
            }
        }

        return $string;
    }
public function toSpec(\DateInterval $interval = null)
    {
        if ((null === $interval) && isset($this)) {
            $interval = $this;
        }

        $string = 'P';

        foreach (self::$date as $property => $suffix) {
            if ($interval->{$property}) {
                $string .= $interval->{$property} . $suffix;
            }
        }

        if ($interval->h || $interval->i || $interval->s) {
            $string .= 'T';

            foreach (self::$time as $property => $suffix) {
                if ($interval->{$property}) {
                    $string .= $interval->{$property} . $suffix;
                }
            }
        }

        return $string;
    }
public function toSpec ( \ DateInterval $ interval = null ) { if ( ( null === $ interval ) && isset ( $ this ) ) { $ interval = $ this ; } $ string = 'P' ; foreach ( self :: $ date as $ property => $ suffix ) { if ( $ interval -> { $ property } ) { $ string .= $ interval -> { $ property } . $ suffix ; } } if ( $ interval -> h || $ interval -> i || $ interval -> s ) { $ string .= 'T' ; foreach ( self :: $ time as $ property => $ suffix ) { if ( $ interval -> { $ property } ) { $ string .= $ interval -> { $ property } . $ suffix ; } } } return $ string ; }
Returns the interval specification.

@param \DateInterval $interval The date interval.

@return string The interval specification.
Returns the interval specification .