|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-07 13:56 UTC] ko dot fivestar at gmail dot com
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
Patchesphp_bug52015.diff (last revision 2010-06-07 14:03 UTC by degeberg@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 22:00:02 2025 UTC |
Exactly same issue as described by ko dot fivestar at gmail dot com happens on OSX PHP v5.6.11 php -v PHP 5.6.11 (cli) (built: Jul 10 2015 22:36:04) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans Is there any estimate on when this is going to be resolved?