ID:               42311
 Updated by:       [EMAIL PROTECTED]
 Reported By:      robin_fernandes at uk dot ibm dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         Date/time related
 Operating System: Windows
 PHP Version:      5.2.3
-Assigned To:      
+Assigned To:      derick
 New Comment:

Assigned to the ext/date maintainer.


Previous Comments:
------------------------------------------------------------------------

[2007-08-15 13:53:16] robin_fernandes at uk dot ibm dot com

Below is a suggested patch which modifies the test to allow for a 1
second margin between the timestamps. I have confirmed the resulting
test passes consistently on Windows on PHP 5.2.3, but have done no
further testing.


Index: C:/php5-latest-phpt/ext/date/tests/bug35885.phpt
===================================================================
--- C:/php5-latest-phpt/ext/date/tests/bug35885.phpt    (revision 13029)
+++ C:/php5-latest-phpt/ext/date/tests/bug35885.phpt    (working copy)
@@ -4,15 +4,15 @@
 <?php
 date_default_timezone_set("UTC");
 
-$ts = date(DATE_ISO8601, strtotime('NOW'));
-$ts2 = date(DATE_ISO8601, time());
+$ts = strtotime('NOW');
+$ts2 = time();
 
-$res = ($ts == $ts2);
+$res = ($ts == $ts2) || ($ts == $ts2-1);
 var_dump($res);
 
 if (!$res) {
-       var_dump($ts);
-       var_dump($ts2);
+       var_dump(date(DATE_ISO8601, $ts));
+       var_dump(date(DATE_ISO8601, $ts2));
 }
 
 ?>

------------------------------------------------------------------------

[2007-08-15 13:48:21] robin_fernandes at uk dot ibm dot com

Description:
------------
Test http://lxr.php.net/source/php-src/ext/date/tests/bug35885.phpt
compares two time stamps representing the current time. However, these
timestamps are seized in separate statements.

The comparison fails intermittently, because the seconds occasionally
tick over between the two calls.

Below is bug35885.phpt enclosed in a loop to prove that it fails
intermittently. It will break out of the loop on failure. Expected time
to failure is less than 10 seconds.

Reproduce code:
---------------
<?php
date_default_timezone_set("UTC");

while (true) {
        $ts = date(DATE_ISO8601, strtotime('NOW'));
        $ts2 = date(DATE_ISO8601, time());
        
        $res = ($ts == $ts2);
        var_dump($res);
        
        if (!$res) {
                var_dump($ts);
                var_dump($ts2);
                break;
        }
}
?>

Expected result:
----------------
N/A (loop)

Actual result:
--------------
bool(true)
bool(true)
[...]
bool(true)
bool(false)
string(24) "2007-08-15T13:26:05+0000"
string(24) "2007-08-15T13:26:06+0000"


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42311&edit=1

Reply via email to