1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merged pull request #14581

This commit is contained in:
Derick Rethans
2024-08-21 10:59:30 +01:00
4 changed files with 63 additions and 5 deletions

4
NEWS
View File

@@ -15,6 +15,10 @@ PHP NEWS
. Fixed bug GH-15501 (Windows HAVE_<header>_H macros defined to 1 or
undefined). (Peter Kokot)
- Date:
. Fixed bug GH-13773 (DatePeriod not taking into account microseconds for end
date). (Mark Bennewitz, Derick)
- MySQLnd:
. Fixed bug GH-15432 (Heap corruption when querying a vector). (cmb,
Kamil Tekiela)

View File

@@ -1578,11 +1578,15 @@ static zend_result date_period_it_has_more(zend_object_iterator *iter)
php_period_obj *object = Z_PHPPERIOD_P(&iterator->intern.data);
if (object->end) {
if (object->include_end_date) {
return object->current->sse <= object->end->sse ? SUCCESS : FAILURE;
} else {
return object->current->sse < object->end->sse ? SUCCESS : FAILURE;
if (object->current->sse == object->end->sse) {
if (object->include_end_date) {
return object->current->us <= object->end->us ? SUCCESS : FAILURE;
} else {
return object->current->us < object->end->us ? SUCCESS : FAILURE;
}
}
return object->current->sse < object->end->sse ? SUCCESS : FAILURE;
} else {
return (iterator->current_index < object->recurrences) ? SUCCESS : FAILURE;
}

View File

@@ -16,4 +16,3 @@ foreach (new DatePeriod($start, $interval, $end, DatePeriod::INCLUDE_END_DATE) a
2010-06-08
2010-06-09
2010-06-10

View File

@@ -0,0 +1,51 @@
--TEST--
DatePeriod: take microseconds into account
--FILE--
<?php
date_default_timezone_set('UTC');
$start = new DateTime('2010-06-07T01:02:03.456789');
$end = new DateTime('2010-06-10T01:02:03.456789');
$interval = new DateInterval('P1D');
echo "from " . $start->format('Y-m-d H:i:s.u') . " to " . $end->format('Y-m-d H:i:s.u') . " (exclusive)\n";
foreach (new DatePeriod($start, $interval, $end) as $day) {
echo $day->format('Y-m-d H:i:s.u') . "\n";
}
echo "from " . $start->format('Y-m-d H:i:s.u') . " to " . $end->format('Y-m-d H:i:s.u') . " (inclusive)\n";
foreach (new DatePeriod($start, $interval, $end, DatePeriod::INCLUDE_END_DATE) as $day) {
echo $day->format('Y-m-d H:i:s.u') . "\n";
}
$end = new DateTime('2010-06-10T01:02:03.456790');
echo "from " . $start->format('Y-m-d H:i:s.u') . " to " . $end->format('Y-m-d H:i:s.u') . " (exclusive)\n";
foreach (new DatePeriod($start, $interval, $end) as $day) {
echo $day->format('Y-m-d H:i:s.u') . "\n";
}
$end = new DateTime('2010-06-10T01:02:03.456788');
echo "from " . $start->format('Y-m-d H:i:s.u') . " to " . $end->format('Y-m-d H:i:s.u') . " (inclusive)\n";
foreach (new DatePeriod($start, $interval, $end, DatePeriod::INCLUDE_END_DATE) as $day) {
echo $day->format('Y-m-d H:i:s.u') . "\n";
}
?>
--EXPECT--
from 2010-06-07 01:02:03.456789 to 2010-06-10 01:02:03.456789 (exclusive)
2010-06-07 01:02:03.456789
2010-06-08 01:02:03.456789
2010-06-09 01:02:03.456789
from 2010-06-07 01:02:03.456789 to 2010-06-10 01:02:03.456789 (inclusive)
2010-06-07 01:02:03.456789
2010-06-08 01:02:03.456789
2010-06-09 01:02:03.456789
2010-06-10 01:02:03.456789
from 2010-06-07 01:02:03.456789 to 2010-06-10 01:02:03.456790 (exclusive)
2010-06-07 01:02:03.456789
2010-06-08 01:02:03.456789
2010-06-09 01:02:03.456789
2010-06-10 01:02:03.456789
from 2010-06-07 01:02:03.456789 to 2010-06-10 01:02:03.456788 (inclusive)
2010-06-07 01:02:03.456789
2010-06-08 01:02:03.456789
2010-06-09 01:02:03.456789