diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/date/php_date.c | 1 | ||||
-rw-r--r-- | ext/date/tests/bug79396-forward-transition-settime.phpt | 24 |
3 files changed, 29 insertions, 0 deletions
@@ -10,6 +10,10 @@ PHP NEWS - CURL: . Fixed bug #79199 (curl_copy_handle() memory leak). (cmb) +- Date: + . Fixed bug #79396 (DateTime hour incorrect during DST jump forward). (Nate + Brunette) + - SimpleXML: . Fixed bug #61597 (SXE properties may lack attributes and content). (cmb) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 705057766a..8c6dfbbe3e 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3573,6 +3573,7 @@ static void php_date_time_set(zval *object, zend_long h, zend_long i, zend_long dateobj->time->s = s; dateobj->time->us = ms; timelib_update_ts(dateobj->time, NULL); + timelib_update_from_sse(dateobj->time); } /* }}} */ /* {{{ proto DateTime date_time_set(DateTime object, int hour, int minute[, int second[, int microseconds]]) diff --git a/ext/date/tests/bug79396-forward-transition-settime.phpt b/ext/date/tests/bug79396-forward-transition-settime.phpt new file mode 100644 index 0000000000..95bf2f20b6 --- /dev/null +++ b/ext/date/tests/bug79396-forward-transition-settime.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test for setting Date/Time during a forward DST transition +--FILE-- +<?php +date_default_timezone_set('America/Chicago'); + +$date = new DateTime('2020-03-08 01:30:00'); +echo $date->setTime(2, 0)->format('Y-m-d H:i:s T/e - U') . "\n"; + +$date = new DateTime('2020-03-08 01:30:00'); +echo $date->setTime(2, 30)->format('Y-m-d H:i:s T/e - U') . "\n"; + +$date = new DateTime('2020-03-08 01:30:00'); +echo $date->setTime(3, 0)->format('Y-m-d H:i:s T/e - U') . "\n"; + +$date = new DateTime('2020-03-08 01:30:00'); +echo $date->setTime(1, 59, 59)->format('Y-m-d H:i:s T/e - U') . "\n"; + +?> +--EXPECT-- +2020-03-08 03:00:00 CDT/America/Chicago - 1583654400 +2020-03-08 03:30:00 CDT/America/Chicago - 1583656200 +2020-03-08 03:00:00 CDT/America/Chicago - 1583654400 +2020-03-08 01:59:59 CST/America/Chicago - 1583654399 |