]> granicus.if.org Git - php/commitdiff
Date comparsion was fixed to compare dates with different time zones.
authorDmitry Stogov <dmitry@php.net>
Mon, 12 Jan 2004 15:18:13 +0000 (15:18 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 12 Jan 2004 15:18:13 +0000 (15:18 +0000)
ext/soap/interop/client_round2_params.php
ext/soap/interop/test.utility.php

index c7a8245924a3419a61e3915b5d512337cec7e550..0cadd979a746a544857aeb8c7b86808e58648605 100644 (file)
@@ -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
index 50f85f1cd8510d736faca124aec7e726c7ff5b8a..04f4e6d4c3ce6a466509aaa8d3783aeeacf329fd 100644 (file)
@@ -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;