mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-8.1' into PHP-8.2
This commit is contained in:
commit
6b212b6dee
@ -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);
|
||||
|
30
ext/date/tests/gh9891.phpt
Normal file
30
ext/date/tests/gh9891.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user