Merge branch 'PHP-8.1' into PHP-8.2

This commit is contained in:
Derick Rethans 2022-12-20 16:06:55 +00:00
commit 6b212b6dee
2 changed files with 34 additions and 0 deletions

View File

@ -3052,6 +3052,10 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{
dateobj->time->us = tmp_time->us;
}
if (tmp_time->have_zone && tmp_time->zone_type == TIMELIB_ZONETYPE_OFFSET) {
timelib_set_timezone_from_offset(dateobj->time, tmp_time->z);
}
timelib_time_dtor(tmp_time);
timelib_update_ts(dateobj->time, NULL);

View File

@ -0,0 +1,30 @@
--TEST--
Bug GH-9891 (DateTime modify with unixtimestamp (@) must work like setTimestamp)
--FILE--
<?php
$m = new DateTime('2022-12-20 14:30:25', new DateTimeZone('Europe/Paris'));
$m->modify('@1234567890');
var_dump($m->getTimeStamp());
echo "=======\n";
$a = new DateTime('2022-11-01 13:30:00', new DateTimezone('America/Lima'));
$b = clone $a;
echo '$a: ', $a->format(DateTime::ATOM), "\n";
echo '$b: ', $b->format(DateTime::ATOM), "\n";
echo '$a: @', $a->getTimestamp(), "\n";
echo '$b: setTimestamp(', $b->getTimestamp(), ")\n";
$a->modify('@' . $a->getTimestamp());
$b->setTimestamp($b->getTimestamp());
echo '$a: ', $a->format(DateTime::ATOM), "\n";
echo '$b: ', $b->format(DateTime::ATOM), "\n";
?>
--EXPECT--
int(1234567890)
=======
$a: 2022-11-01T13:30:00-05:00
$b: 2022-11-01T13:30:00-05:00
$a: @1667327400
$b: setTimestamp(1667327400)
$a: 2022-11-01T18:30:00+00:00
$b: 2022-11-01T13:30:00-05:00