diff options
| author | Dmitry Stogov <dmitry@php.net> | 2004-01-12 15:18:13 +0000 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2004-01-12 15:18:13 +0000 |
| commit | 3afeac36275460eebd5ffd93836ab799ad07bb32 (patch) | |
| tree | c19fb62400e5091e7695afdc9a1d59050f65dcf9 | |
| parent | d32ef43c3a781ebdb4d0178b2aabd3cef4cc18d0 (diff) | |
| download | php-git-3afeac36275460eebd5ffd93836ab799ad07bb32.tar.gz | |
Date comparsion was fixed to compare dates with different time zones.
| -rw-r--r-- | ext/soap/interop/client_round2_params.php | 4 | ||||
| -rw-r--r-- | ext/soap/interop/test.utility.php | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/ext/soap/interop/client_round2_params.php b/ext/soap/interop/client_round2_params.php index c7a8245924..0cadd979a7 100644 --- a/ext/soap/interop/client_round2_params.php +++ b/ext/soap/interop/client_round2_params.php @@ -279,9 +279,9 @@ $soap_tests['base'][] = new SOAP_Test('echoDecimal', array('inputDecimal' => // Base echoDate # php-soap doesn't handle datetime types properly yet -$soap_tests['base'][] = new SOAP_Test('echoDate', array('inputDate' => '2001-05-24T17:31:41Z')); +$soap_tests['base'][] = new SOAP_Test('echoDate', array('inputDate' => '2001-05-24T17:31:41Z'), null, 'date_compare'); $soap_tests['base'][] = new SOAP_Test('echoDate', array('inputDate' => - soap_value('inputDate','2001-05-24T17:31:41Z',XSD_DATETIME)));#'2001-04-25T13:31:41-0700' + soap_value('inputDate','2001-05-24T17:31:41Z',XSD_DATETIME)), null, 'date_compare'); //*********************************************************** // Base echoBoolean diff --git a/ext/soap/interop/test.utility.php b/ext/soap/interop/test.utility.php index 50f85f1cd8..04f4e6d4c3 100644 --- a/ext/soap/interop/test.utility.php +++ b/ext/soap/interop/test.utility.php @@ -1,5 +1,34 @@ <?php +function timestamp_to_soap_datetime($t) { + return date('Y-m-d\TH:i:sO',$t); +} + +function soap_datetime_to_timestamp($t) { + /* Ignore Microsecconds */ + $iso8601 = '(-?[0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]*)?(Z|[+\-][0-9]{4}|[+\-][0-9]{2}:[0-9]{2})?'; + if (!is_int($t)) { + if (!ereg($iso8601,$t,$r)) { + return false; + } + $t = mktime($r[6],$r[5],$r[4],$r[3],$r[2],$r[1]); + $op = substr($regs[8],0,1); + $h = substr($regs[8],1,2); + if (strstr($regs[8],':')) { + $m = substr($regs[8],4,2); + } else { + $m = substr($regs[8],3,2); + } + $t += (($op == "-"?-1:1) * $h * 60 + $m) * 60; + } + return t; +} + +function date_compare($f1,$f2) +{ + return soap_datetime_to_timestamp($f1) == soap_datetime_to_timestamp($f2); +} + function hex_compare($f1, $f2) { return strcasecmp($f1,$f2) == 0; |
