From: Operating system: Ubuntu 10.04 PHP version: 5.3.2 Package: Date/time related Bug Type: Bug Bug description:Ending date is ignored while iterating DatePeriod
Description: ------------ When passing DateTime objects to first and third argument of DatePeriod constructor, the specified date on the third argument is not being interated when both DateTime object contains same time value. After looking through ext/date/php_date.c, date_period_it_has_more() function (line 1831) had following code: --------------- return object->start->sse < object->end->sse ? SUCCESS : FAILURE; --------------- While the operator "<" is currently used to compare values, operator "<=" is more appropriate for this content. Test script: --------------- $period = new \DatePeriod( new \DateTime('2010-06-01'), new \DateInterval('P1D'), new \DateTime('2010-06-03') ); foreach ($period as $day) { echo $day->format('Y-m-d') . "\n"; } Expected result: ---------------- 2010-06-01 2010-06-02 2010-06-03 Actual result: -------------- 2010-06-01 2010-06-02 -- Edit bug report at http://bugs.php.net/bug.php?id=52015&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52015&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52015&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52015&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52015&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52015&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52015&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52015&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52015&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52015&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52015&r=support Expected behavior: http://bugs.php.net/fix.php?id=52015&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52015&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52015&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52015&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52015&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52015&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52015&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52015&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52015&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52015&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52015&r=mysqlcfg