Skip to content

Commit

Permalink
Merge branch 'PHP-8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Apr 22, 2022
2 parents bf6c96a + 15ee285 commit a690a56
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions ext/date/tests/bug73837.phpt
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
--TEST--
Bug #73837: Milliseconds in DateTime()
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
$collect = [];

for ( $i = 0; $i < 1000; $i++ )
{
$a = new DateTime();
$key = "s" . $a->format( "u" );
$collect[$key] = true;
$startTS = time();
$prev_dt = new DateTime();
while (time() < $startTS + 2) {
$dt = new DateTime();
if ($prev_dt > $dt) {
var_dump($prev_dt->format("Y-m-d H:i:s.u"));
var_dump($dt->format("Y-m-d H:i:s.u"));
break;
}
$prev_dt = $dt;
}

// For low-resolution clocks, we may construct many objects in the same tick.
var_dump($n = count( $collect ));
echo $n > 200 ? "microseconds differ\n" : "microseconds do not differ enough ($n)\n";
echo "Finished\n";
?>
--EXPECTF--
int(%d)
microseconds differ
Finished

0 comments on commit a690a56

Please sign in to comment.