Edit report at http://bugs.php.net/bug.php?id=46874&edit=1

 ID:                 46874
 Updated by:         der...@php.net
 Reported by:        php at michaelcrumley dot com
 Summary:            DatePeriod not resetting after foreach loop
-Status:             Bogus
+Status:             Closed
 Type:               Bug
 Package:            Date/time related
 Operating System:   WIN32
 PHP Version:        5.3.0alpha3
-Assigned To:        
+Assigned To:        derick
 Block user comment: 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.

(And duplicate of #53668)


Previous Comments:
------------------------------------------------------------------------
[2010-08-30 17:35:43] der...@php.net

Automatic comment from SVN on behalf of derick
Revision: http://svn.php.net/viewvc/?view=revision&revision=302888
Log: - Added test for bug #46874 (same as #52668).

------------------------------------------------------------------------
[2008-12-16 09:11:06] der...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.

------------------------------------------------------------------------
[2008-12-15 20:55:18] php at michaelcrumley dot com

Description:
------------
After looping through a DatePeriod object, the current date is not reset
so looping again starts at the same date. Maybe that is the intended
behavior, but I would expect it to start at the same date each time.



Reproduce code:
---------------
$dp = new DatePeriod('R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M');



foreach ($dp as $date) {

    echo $date->format("Y-m-d H:i:s\n");

}



echo "\n";



// this should repeat the same range

foreach ($dp as $date) {

    echo $date->format("Y-m-d H:i:s\n");

}



Expected result:
----------------
2008-03-01 13:00:00

2009-05-11 15:30:00

2010-07-21 18:00:00

2011-10-01 20:30:00

2012-12-11 23:00:00

2014-02-22 01:30:00



2008-03-01 13:00:00

2009-05-11 15:30:00

2010-07-21 18:00:00

2011-10-01 20:30:00

2012-12-11 23:00:00

2014-02-22 01:30:00



Actual result:
--------------
2008-03-01 13:00:00

2009-05-11 15:30:00

2010-07-21 18:00:00

2011-10-01 20:30:00

2012-12-11 23:00:00

2014-02-22 01:30:00



2015-05-02 04:00:00

2016-07-12 06:30:00

2017-09-22 09:00:00

2018-12-02 11:30:00

2020-02-12 14:00:00

2021-04-22 16:30:00




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=46874&edit=1

Reply via email to