Skip to content

Commit 77cae26

Browse files
author
danielc
committed
Provide test for DateTime::add() issue (for discussion on internals, bugs.php.net is down).
git-svn-id: http://svn.php.net/repository/php/php-src/trunk@312289 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent b43bea8 commit 77cae26

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

ext/date/tests/bug.add.zone2.phpt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
DateTime::add() mistakenly modifies objects having zone type 2
3+
--CREDITS--
4+
Daniel Convissor <[email protected]>
5+
--XFAIL--
6+
Bug exists
7+
--FILE--
8+
<?php
9+
10+
date_default_timezone_set('America/New_York');
11+
12+
$interval = new DateInterval('PT2H1M');
13+
14+
$date3 = new DateTime('2010-10-04 02:18:48');
15+
$date2 = new DateTime('2010-10-04 02:18:48 EDT');
16+
17+
echo 'Zone Type 3: ' . $date3->format('Y-m-d H:i:s T') . "\n";
18+
echo 'Zone Type 2: ' . $date2->format('Y-m-d H:i:s T') . "\n";
19+
20+
echo $interval->format('Add %h hours %i minutes') . "\n";
21+
$date3->add($interval);
22+
$date2->add($interval);
23+
24+
echo 'Zone Type 3: ' . $date3->format('Y-m-d H:i:s T') . "\n";
25+
echo 'Zone Type 2: ' . $date2->format('Y-m-d H:i:s T') . "\n";
26+
27+
?>
28+
--EXPECT--
29+
Zone Type 3: 2010-10-04 02:18:48 EDT
30+
Zone Type 2: 2010-10-04 02:18:48 EDT
31+
Add 2 hours 1 minutes
32+
Zone Type 3: 2010-10-04 04:19:48 EDT
33+
Zone Type 2: 2010-10-04 04:19:48 EDT

0 commit comments

Comments
 (0)