function _duration_string( $duration ) {
   $duration = (string) trim( $duration );
   while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
     if( 0 < strlen( $duration ))
       $duration = substr( $duration, 1 );
     else
       return false; // no leading P !?!?
   }
   $duration = substr( $duration, 1 ); // skip P
   $duration = str_replace ( 't', 'T', $duration );
   $duration = str_replace ( 'T', '', $duration );
   $output = array();
   $val    = null;
   for( $ix=0; $ix < strlen( $duration ); $ix++ ) {
     switch( strtoupper( $duration{$ix} )) {
      case 'W':
        $output['week'] = $val;
        $val            = null;
        break;
      case 'D':
        $output['day']  = $val;
        $val            = null;
        break;
      case 'H':
        $output['hour'] = $val;
        $val            = null;
        break;
      case 'M':
        $output['min']  = $val;
        $val            = null;
        break;
      case 'S':
        $output['sec']  = $val;
        $val            = null;
        break;
      default:
        if( !ctype_digit( $duration{$ix} ))
          return false; // unknown duration controll character  !?!?
        else
          $val .= $duration{$ix};
     }
   }
   return $this->_duration_array( $output );
  }
function _duration_string( $duration ) {
   $duration = (string) trim( $duration );
   while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
     if( 0 < strlen( $duration ))
       $duration = substr( $duration, 1 );
     else
       return false; // no leading P !?!?
   }
   $duration = substr( $duration, 1 ); // skip P
   $duration = str_replace ( 't', 'T', $duration );
   $duration = str_replace ( 'T', '', $duration );
   $output = array();
   $val    = null;
   for( $ix=0; $ix < strlen( $duration ); $ix++ ) {
     switch( strtoupper( $duration{$ix} )) {
      case 'W':
        $output['week'] = $val;
        $val            = null;
        break;
      case 'D':
        $output['day']  = $val;
        $val            = null;
        break;
      case 'H':
        $output['hour'] = $val;
        $val            = null;
        break;
      case 'M':
        $output['min']  = $val;
        $val            = null;
        break;
      case 'S':
        $output['sec']  = $val;
        $val            = null;
        break;
      default:
        if( !ctype_digit( $duration{$ix} ))
          return false; // unknown duration controll character  !?!?
        else
          $val .= $duration{$ix};
     }
   }
   return $this->_duration_array( $output );
  }
function _duration_string ( $ duration ) { $ duration = ( string ) trim ( $ duration ) ; while ( 'P' != strtoupper ( substr ( $ duration , 0 , 1 ) ) ) { if ( 0 < strlen ( $ duration ) ) $ duration = substr ( $ duration , 1 ) ; else return false ; // no leading P !?!? } $ duration = substr ( $ duration , 1 ) ; // skip P $ duration = str_replace ( 't' , 'T' , $ duration ) ; $ duration = str_replace ( 'T' , '' , $ duration ) ; $ output = array ( ) ; $ val = null ; for ( $ ix = 0 ; $ ix < strlen ( $ duration ) ; $ ix ++ ) { switch ( strtoupper ( $ duration { $ ix } ) ) { case 'W' : $ output [ 'week' ] = $ val ; $ val = null ; break ; case 'D' : $ output [ 'day' ] = $ val ; $ val = null ; break ; case 'H' : $ output [ 'hour' ] = $ val ; $ val = null ; break ; case 'M' : $ output [ 'min' ] = $ val ; $ val = null ; break ; case 'S' : $ output [ 'sec' ] = $ val ; $ val = null ; break ; default : if ( ! ctype_digit ( $ duration { $ ix } ) ) return false ; // unknown duration controll character  !?!? else $ val .= $ duration { $ ix } ; } } return $ this -> _duration_array ( $ output ) ; }
ensures internal duration format for input in string format

@author Kjell-Inge Gustafsson <ical@kigkonsult.se>
@since 2.0.5 - 2007-03-14
@param string $duration
@return array
ensures internal duration format for input in string format