Bug #54340 [Asn->Csd]: DateTime::add() method bug

From: Date: Tue, 22 Mar 2011 08:33:29 +0000
Subject: Bug #54340 [Asn->Csd]: DateTime::add() method bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159693@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=54340&edit=1 ID: 54340 Updated by: aharvey@php.net Reported by: 1cdecoder at gmail dot com Summary: DateTime::add() method bug -Status: Assigned +Status: Closed Type: Bug Package: Date/time related Operating System: Windows 7 x64 PHP Version: 5.3.6 Assigned To: aharvey Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2011-03-22 09:33:25] aharvey@php.net Automatic comment from SVN on behalf of aharvey Revision: http://svn.php.net/viewvc/?view=revision&revision=309535 Log: Fix bug #54340 (DateTime::add() method bug). ------------------------------------------------------------------------ [2011-03-22 09:27:34] aharvey@php.net Looks like we don't reset the DateTime object's timelib_rel_time structure properly before altering it in add() (and sub(), for that matter), and the first_last_day_of flag is causing issues. Fix forthcoming. ------------------------------------------------------------------------ [2011-03-22 00:29:12] 1cdecoder at gmail dot com Description: ------------ DateTime::add() method bug Test script: --------------- $date = new DateTime('first day of this month'); echo $date->format('Y-m-d H:i:sP'); $date->add(new DateInterval('P1D')); echo $date->format('Y-m-d H:i:sP'); Expected result: ---------------- 2011-03-01 01:17:31+02:00 2011-03-02 01:17:31+02:00 Actual result: -------------- 2011-03-01 01:17:31+02:00 2011-03-01 01:17:31+02:00 ================= ====== BUT ====== ================= $date = new DateTime('first day of this month'); echo $date->format('Y-m-d H:i:sP'); $date->add(new DateInterval('P1M')); echo $date->format('Y-m-d H:i:sP'); Expected result: ---------------- 2011-03-01 01:17:31+02:00 2011-04-01 01:17:31+02:00 Actual result: -------------- 2011-03-01 01:17:31+02:00 2011-04-01 01:17:31+02:00 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54340&edit=1

« previous php.bugs (#159693) next »