php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52668 Iterating over a dateperiod twice is broken
Submitted: 2010-08-22 16:24 UTC Modified: 2010-08-30 17:32 UTC
From: bugs dot php dot net at muh-die-kuh dot de Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bugs dot php dot net at muh-die-kuh dot de
New email:
PHP Version: OS:

 

 [2010-08-22 16:24 UTC] bugs dot php dot net at muh-die-kuh dot de
Description:
------------
Iterating over a dateperiod twice does not "reset" the iterator,
but starts the second iteration at the endate.

This is kindof an duplicate of #46874, but Derick asked me to add it anyways.

Test script:
---------------
<?php

$start    = new DateTime('20101212');
$interval = DateInterval::createFromDateString('next day');
$dp = new DatePeriod($start, $interval, 0);
foreach($dp as $dt) {
    echo $dt->format('r') . "\n"; // Sun, 12 Dec 2010 00:00:00 +0100
}
foreach($dp as $dt) {
    echo $dt->format('r') . "\n"; // Mon, 13 Dec 2010 00:00:00 +0100
}

Expected result:
----------------
Sun, 12 Dec 2010 00:00:00 +0100
Sun, 12 Dec 2010 00:00:00 +0100

Actual result:
--------------
Sun, 12 Dec 2010 00:00:00 +0100
Mon, 13 Dec 2010 00:00:00 +0100

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-23 14:31 UTC] johannes@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-08-28 16:24 UTC] derick@php.net
Another example at: http://php.codepad.org/vjXDqjc1
 [2010-08-30 17:32 UTC] derick@php.net
Automatic comment from SVN on behalf of derick
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302887
Log: - Fixed bug #52668 (Iterating over a dateperiod twice is broken).
 [2010-08-30 17:32 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2010-08-30 17:32 UTC] derick@php.net
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.


 [2010-08-30 17:35 UTC] derick@php.net
Automatic comment from SVN on behalf of derick
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302888
Log: - Added test for bug #46874 (same as #52668).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 15:01:30 2024 UTC