mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Fix GH-10583: DateTime modify with tz pattern should not update linked timezone
This commit is contained in:
parent
8424b5caaa
commit
cbac68df6b
4
NEWS
4
NEWS
@ -16,6 +16,10 @@ PHP NEWS
|
||||
. Fixed bug GH-10810 (Fix NUL byte terminating Exception::__toString()).
|
||||
(ilutov)
|
||||
|
||||
- Date:
|
||||
. Fixed bug GH-10583 (DateTime modify with tz pattern should not update
|
||||
linked timezone). (Derick)
|
||||
|
||||
- FPM:
|
||||
. Fixed bug GH-10611 (fpm_env_init_main leaks environ). (nielsdos)
|
||||
. Destroy file_handle in fpm_main. (Jakub Zelenka, nielsdos)
|
||||
|
@ -2897,8 +2897,14 @@ static int 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);
|
||||
/* Reset timezone to UTC if we detect a "@<ts>" modification */
|
||||
if (
|
||||
tmp_time->y == 1970 && tmp_time->m == 1 && tmp_time->d == 1 &&
|
||||
tmp_time->h == 0 && tmp_time->i == 0 && tmp_time->s == 0 && tmp_time->us == 0 &&
|
||||
tmp_time->have_zone && tmp_time->zone_type == TIMELIB_ZONETYPE_OFFSET &&
|
||||
tmp_time->z == 0 && tmp_time->dst == 0
|
||||
) {
|
||||
timelib_set_timezone_from_offset(dateobj->time, 0);
|
||||
}
|
||||
|
||||
timelib_time_dtor(tmp_time);
|
||||
|
18
ext/date/tests/gh10583.phpt
Normal file
18
ext/date/tests/gh10583.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug GH-10583 (DateTime modify with tz pattern should not update linked timezone)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$dt = new DateTime('2015-01-01 00:00:00+00:00');
|
||||
var_dump($dt->format('c'));
|
||||
var_dump($dt->modify('+1 s')->format('c'));
|
||||
|
||||
$dt = new DateTimeImmutable('2015-01-01 00:00:00+00:00');
|
||||
var_dump($dt->format('c'));
|
||||
var_dump($dt->modify('+1 s')->format('c'));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(25) "2015-01-01T00:00:00+00:00"
|
||||
string(25) "2015-01-01T00:00:00+00:00"
|
||||
string(25) "2015-01-01T00:00:00+00:00"
|
||||
string(25) "2015-01-01T00:00:00+00:00"
|
Loading…
Reference in New Issue
Block a user