xref: /PHP-8.2/ext/date/tests/bug-gh8964-001.phpt (revision 7831a1ca)
1--TEST--
2Test for bug GH-8964: DateTime object comparison after applying delta less than 1 second
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$actual = new DateTimeImmutable("2022-07-21 15:00:10");
8$delta    = new \DateInterval(sprintf('PT%dS', 0));
9$delta->f = 0.9;
10
11$expectedLower = $actual->sub($delta);
12$expectedUpper = $actual->add($delta);
13
14echo $expectedLower->format( 'H:i:s.u U' ), "\n";
15echo $actual       ->format( 'H:i:s.u U' ), "\n";
16echo $expectedUpper->format( 'H:i:s.u U' ), "\n";
17
18var_dump($actual < $expectedLower, $actual > $expectedUpper);
19?>
20--EXPECTF--
2115:00:09.100000 1658415609
2215:00:10.000000 1658415610
2315:00:10.900000 1658415610
24bool(false)
25bool(false)
26