src/Common/TimeExpression.php
public static function dateIntervalToIntervalSpec(DateInterval $di): string
    {
        $time_parts = ['h', 'i', 's', 'f'];
        $time_token_set = false;
        $interval_spec = 'P';

        foreach (array_keys(self::$tokens) as $token) {
            if (in_array($token, $time_parts) && $time_token_set === false && $di->$token > 0) {
                $interval_spec .= 'T';
                $time_token_set = true;
            }
            if ($di->$token > 0) {
                $token_string = $token;
                if (array_key_exists($token, self::$tokensSubstitution)) {
                    $token_string = self::$tokensSubstitution[$token];
                }
                $interval_spec .= $di->$token.strtoupper($token_string);
            }
        }

        return $interval_spec;
    }
public static function dateIntervalToIntervalSpec(DateInterval $di): string
    {
        $time_parts = ['h', 'i', 's', 'f'];
        $time_token_set = false;
        $interval_spec = 'P';

        foreach (array_keys(self::$tokens) as $token) {
            if (in_array($token, $time_parts) && $time_token_set === false && $di->$token > 0) {
                $interval_spec .= 'T';
                $time_token_set = true;
            }
            if ($di->$token > 0) {
                $token_string = $token;
                if (array_key_exists($token, self::$tokensSubstitution)) {
                    $token_string = self::$tokensSubstitution[$token];
                }
                $interval_spec .= $di->$token.strtoupper($token_string);
            }
        }

        return $interval_spec;
    }
public static function dateIntervalToIntervalSpec ( DateInterval $ di ) : string { $ time_parts = [ 'h' , 'i' , 's' , 'f' ] ; $ time_token_set = false ; $ interval_spec = 'P' ; foreach ( array_keys ( self :: $ tokens ) as $ token ) { if ( in_array ( $ token , $ time_parts ) && $ time_token_set === false && $ di -> $ token > 0 ) { $ interval_spec .= 'T' ; $ time_token_set = true ; } if ( $ di -> $ token > 0 ) { $ token_string = $ token ; if ( array_key_exists ( $ token , self :: $ tokensSubstitution ) ) { $ token_string = self :: $ tokensSubstitution [ $ token ] ; } $ interval_spec .= $ di -> $ token . strtoupper ( $ token_string ) ; } } return $ interval_spec ; }
Transform a DateInterval to a valid ISO8601 interval

@param DateInterval $di
@return string
Transform a DateInterval to a valid ISO8601 interval