Data Structures | Functions

webservice/soap/lib/class.nusoap_base.php File Reference

Go to the source code of this file.

Data Structures

class  nusoap_base
 nusoap_base More...

Functions

 timestamp_to_iso8601 ($timestamp, $utc=true)
 convert unix timestamp to ISO 8601 compliant date string
 iso8601_to_timestamp ($datestr)
 convert ISO 8601 compliant date string to unix timestamp
 usleepWindows ($usec)

Function Documentation

iso8601_to_timestamp ( datestr  ) 

convert ISO 8601 compliant date string to unix timestamp

Parameters:
string $datestr ISO 8601 compliant date string public

Definition at line 614 of file class.nusoap_base.php.

                                       {
        $eregStr =
        '([0-9]{4})-'.  // centuries & years CCYY-
        '([0-9]{2})-'.  // months MM-
        '([0-9]{2})'.   // days DD
        'T'.                    // separator T
        '([0-9]{2}):'.  // hours hh:
        '([0-9]{2}):'.  // minutes mm:
        '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
        '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
        if(ereg($eregStr,$datestr,$regs)){
                // not utc
                if($regs[8] != 'Z'){
                        $op = substr($regs[8],0,1);
                        $h = substr($regs[8],1,2);
                        $m = substr($regs[8],strlen($regs[8])-2,2);
                        if($op == '-'){
                                $regs[4] = $regs[4] + $h;
                                $regs[5] = $regs[5] + $m;
                        } elseif($op == '+'){
                                $regs[4] = $regs[4] - $h;
                                $regs[5] = $regs[5] - $m;
                        }
                }
                return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
        } else {
                return false;
        }
}

timestamp_to_iso8601 ( timestamp,
utc = true 
)

convert unix timestamp to ISO 8601 compliant date string

Parameters:
string $timestamp Unix time stamp public

Definition at line 586 of file class.nusoap_base.php.

                                                   {
        $datestr = date('Y-m-d\TH:i:sO',$timestamp);
        if($utc){
                $eregStr =
                '([0-9]{4})-'.  // centuries & years CCYY-
                '([0-9]{2})-'.  // months MM-
                '([0-9]{2})'.   // days DD
                'T'.                    // separator T
                '([0-9]{2}):'.  // hours hh:
                '([0-9]{2}):'.  // minutes mm:
                '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
                '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's

                if(ereg($eregStr,$datestr,$regs)){
                        return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
                }
                return false;
        } else {
                return $datestr;
        }
}

usleepWindows ( usec  ) 

Definition at line 644 of file class.nusoap_base.php.

References $start.

{
        $start = gettimeofday();
        
        do
        {
                $stop = gettimeofday();
                $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
                + $stop['usec'] - $start['usec'];
        }
        while ($timePassed < $usec);
}