示例#1
0
 function getduration($seconds)
 {
     $neg = '';
     if ($seconds < 0) {
         $neg = '-';
         $seconds = $seconds * -1;
     }
     $_mi = 60;
     $_h = $_mi * 60;
     $_d = $_h * 24;
     // XXX how do we properly handle month and year values?
     $_m = $_d * 30;
     $_y = $_d * 365;
     SOAP_Type_duration::mod($seconds, $_y, $y, $seconds);
     SOAP_Type_duration::mod($seconds, $_m, $m, $seconds);
     SOAP_Type_duration::mod($seconds, $_d, $d, $seconds);
     SOAP_Type_duration::mod($seconds, $_h, $h, $seconds);
     SOAP_Type_duration::mod($seconds, $_mi, $mi, $s);
     $duration = $neg . 'P';
     if ($y) {
         $duration .= $y . 'Y';
     }
     if ($m) {
         $duration .= $m . 'M';
     }
     if ($d) {
         $duration .= $d . 'D';
     }
     if ($h || $mi || $s) {
         $duration .= 'T';
     }
     if ($h) {
         $duration .= $h . 'H';
     }
     if ($mi) {
         $duration .= $mi . 'M';
     }
     if ($s) {
         $duration .= $s . 'S';
     }
     if ($duration == 'P' || $duration == '-P') {
         $duration = 'PT0S';
     }
     return $duration;
 }