mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix flaky DatePeriod test
$start and $end use the H:i:s from the current time. If $end happens on a second boundary, $start + 4 days will include $end, thus performing an extra iteration. Fix this by setting H:i:s to 00:00:00.
This commit is contained in:
parent
dc6586dd9d
commit
8a699372f2
1 changed files with 2 additions and 2 deletions
|
@ -3,8 +3,8 @@ Date Period iterators do not advance on valid()
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$start = DateTime::createFromFormat('Y-m-d', '2022-01-01');
|
$start = DateTime::createFromFormat('Y-m-d H:i:s', '2022-01-01 00:00:00');
|
||||||
$end = DateTime::createFromFormat('Y-m-d', '2022-01-04');
|
$end = DateTime::createFromFormat('Y-m-d H:i:s', '2022-01-04 00:00:00');
|
||||||
$interval = DateInterval::createFromDateString('1 day');
|
$interval = DateInterval::createFromDateString('1 day');
|
||||||
$period = new DatePeriod($start, $interval, $end);
|
$period = new DatePeriod($start, $interval, $end);
|
||||||
$iterator = $period->getIterator();
|
$iterator = $period->getIterator();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue