Skip to content

Commit 9437dcd

Browse files
michaelmoussakrakjoe
authored andcommitted
Add test for bug #52480
1 parent 2030b59 commit 9437dcd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ext/date/tests/bug52480.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #52480 (Incorrect difference using DateInterval)
3+
--XFAIL--
4+
See https://bugs.php.net/bug.php?id=52480
5+
--FILE--
6+
<?php
7+
8+
$expectedDiff = (array) new DateInterval('P30D');
9+
10+
// If the DateInterval object was created by DateTime::diff(), then this is the total
11+
// number of days between the start and end dates. Otherwise, days will be FALSE.
12+
// https://secure.php.net/manual/en/class.dateinterval.php
13+
$expectedDiff['days'] = 30;
14+
15+
foreach (DateTimeZone::listIdentifiers() as $timezone) {
16+
$start = new DateTime('2017-03-01', new DateTimeZone($timezone));
17+
$end = new DateTime('2017-03-31', new DateTimeZone($timezone));
18+
19+
if ($expectedDiff != (array) $start->diff($end)) {
20+
echo "\nWrong result for $timezone!\n";
21+
}
22+
}
23+
?>
24+
===DONE===
25+
--EXPECT--
26+
===DONE===

0 commit comments

Comments
 (0)