Bug #52668 [NEW]: Iterating over a dateperiod twice is broken
| From: | bugs dot php dot net at muh-die-kuh dot de | Date: | Sun, 22 Aug 2010 14:24:48 +0000 |
| Subject: | Bug #52668 [NEW]: Iterating over a dateperiod twice is broken | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-153697@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: 5.3.3
Package: Date/time related
Bug Type: Bug
Bug description:Iterating over a dateperiod twice is broken
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
--
Edit bug report at http://bugs.php.net/bug.php?id=52668&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52668&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52668&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52668&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52668&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52668&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52668&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52668&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52668&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52668&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52668&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52668&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52668&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52668&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52668&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52668&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52668&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52668&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52668&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52668&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52668&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52668&r=mysqlcfg