function _format_duration( $duration ) {
    if( !isset( $duration['week'] ) &&
        !isset( $duration['day'] )  &&
        !isset( $duration['hour'] ) &&
        !isset( $duration['min'] )  &&
        !isset( $duration['sec'] ))
      return;
    $output = 'P';
    if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
      $output       .= $duration['week'].'W';
    else {
      if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
        $output     .= $duration['day'].'D';
      if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
         ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
         ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
        $output     .= 'T';
        if( 0 < $duration['hour'] ) {
          $output   .= $duration['hour'].'H';
          if( 0 < $duration['min'] ) {
            $output .= $duration['min'].'M';
            if( 0 < $duration['sec'] )
              $output .= $duration['sec'].'S';
          }
          elseif( 0 < $duration['sec'] )
            $output .= '0M'.$duration['sec'].'S';
        }
        elseif( 0 < $duration['min'] ) {
          $output   .= '0H'.$duration['min'].'M';
          if( 0 < $duration['sec'] )
            $output .= $duration['sec'].'S';
        }
        elseif( 0 < $duration['sec'] )
          $output   .= '0H0M'.$duration['sec'].'S';
      }
    }
    return $output;
  }
function _format_duration( $duration ) {
    if( !isset( $duration['week'] ) &&
        !isset( $duration['day'] )  &&
        !isset( $duration['hour'] ) &&
        !isset( $duration['min'] )  &&
        !isset( $duration['sec'] ))
      return;
    $output = 'P';
    if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
      $output       .= $duration['week'].'W';
    else {
      if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
        $output     .= $duration['day'].'D';
      if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
         ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
         ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
        $output     .= 'T';
        if( 0 < $duration['hour'] ) {
          $output   .= $duration['hour'].'H';
          if( 0 < $duration['min'] ) {
            $output .= $duration['min'].'M';
            if( 0 < $duration['sec'] )
              $output .= $duration['sec'].'S';
          }
          elseif( 0 < $duration['sec'] )
            $output .= '0M'.$duration['sec'].'S';
        }
        elseif( 0 < $duration['min'] ) {
          $output   .= '0H'.$duration['min'].'M';
          if( 0 < $duration['sec'] )
            $output .= $duration['sec'].'S';
        }
        elseif( 0 < $duration['sec'] )
          $output   .= '0H0M'.$duration['sec'].'S';
      }
    }
    return $output;
  }
function _format_duration ( $ duration ) { if ( ! isset ( $ duration [ 'week' ] ) && ! isset ( $ duration [ 'day' ] ) && ! isset ( $ duration [ 'hour' ] ) && ! isset ( $ duration [ 'min' ] ) && ! isset ( $ duration [ 'sec' ] ) ) return ; $ output = 'P' ; if ( isset ( $ duration [ 'week' ] ) && ( 0 < $ duration [ 'week' ] ) ) $ output .= $ duration [ 'week' ] . 'W' ; else { if ( isset ( $ duration [ 'day' ] ) && ( 0 < $ duration [ 'day' ] ) ) $ output .= $ duration [ 'day' ] . 'D' ; if ( ( isset ( $ duration [ 'hour' ] ) && ( 0 < $ duration [ 'hour' ] ) ) || ( isset ( $ duration [ 'min' ] ) && ( 0 < $ duration [ 'min' ] ) ) || ( isset ( $ duration [ 'sec' ] ) && ( 0 < $ duration [ 'sec' ] ) ) ) { $ output .= 'T' ; if ( 0 < $ duration [ 'hour' ] ) { $ output .= $ duration [ 'hour' ] . 'H' ; if ( 0 < $ duration [ 'min' ] ) { $ output .= $ duration [ 'min' ] . 'M' ; if ( 0 < $ duration [ 'sec' ] ) $ output .= $ duration [ 'sec' ] . 'S' ; } elseif ( 0 < $ duration [ 'sec' ] ) $ output .= '0M' . $ duration [ 'sec' ] . 'S' ; } elseif ( 0 < $ duration [ 'min' ] ) { $ output .= '0H' . $ duration [ 'min' ] . 'M' ; if ( 0 < $ duration [ 'sec' ] ) $ output .= $ duration [ 'sec' ] . 'S' ; } elseif ( 0 < $ duration [ 'sec' ] ) $ output .= '0H0M' . $ duration [ 'sec' ] . 'S' ; } } return $ output ; }
creates formatted output for calendar component property data value type duration

@author Kjell-Inge Gustafsson <ical@kigkonsult.se>
@since 1.x.x - 2007-05-13
@param array $duration ( week, day, hour, min, sec )
@return string
creates formatted output for calendar component property data value type duration