Skip to content

Commit a0c01f3

Browse files
committed
Add test case for GH-9601: DateInterval 1.5s added to DateTimeInterface is rounded down since PHP 8.1.0
1 parent a35b3e7 commit a0c01f3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
different type). (Derick)
1111
. Fixed bug GH-8964 (DateTime object comparison after applying delta less
1212
than 1 second). (Derick)
13+
. Fixed bug GH-9106: (DateInterval 1.5s added to DateTimeInterface is rounded
14+
down since PHP 8.1.0). (Derick)
1315
. Fixed bug #81263 (Wrong result from DateTimeImmutable::diff). (Derick)
1416

1517
- DBA:

ext/date/tests/bug-gh9106.phpt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Test for bug GH-9601: DateInterval 1.5s added to DateTimeInterface is rounded down since PHP 8.1.0
3+
--INI--
4+
date.timezone=UTC
5+
--FILE--
6+
<?php
7+
8+
$start = new \DateTimeImmutable("2020-01-01 00:00:00 UTC");
9+
10+
$oneAndHalfSec = new \DateInterval("PT1S");
11+
$oneAndHalfSec->f = 0.5;
12+
13+
$t1 = $start->add($oneAndHalfSec);
14+
$t2 = $t1->add($oneAndHalfSec);
15+
$t3 = $t2->add($oneAndHalfSec);
16+
$t4 = $t3->add($oneAndHalfSec);
17+
18+
var_dump($start->getTimestamp());
19+
var_dump($t1->getTimestamp());
20+
var_dump($t2->getTimestamp());
21+
var_dump($t3->getTimestamp());
22+
var_dump($t4->getTimestamp());
23+
?>
24+
--EXPECT--
25+
int(1577836800)
26+
int(1577836801)
27+
int(1577836803)
28+
int(1577836804)
29+
int(1577836806)

0 commit comments

Comments
 (0)