diff options
author | Nate Brunette <nate.brunette@wheniwork.com> | 2020-03-18 15:04:46 -0500 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-03-19 08:50:34 +0100 |
commit | d70058a139f3a45898e1f270c840fb64ea1a09f0 (patch) | |
tree | 6d03d29a3ee2ec3a01bd1c744c7d371813e67f83 | |
parent | c00cce3229515eacdb1680f39132ed3ca09cc205 (diff) | |
download | php-git-d70058a139f3a45898e1f270c840fb64ea1a09f0.tar.gz |
Fix #79396: DateTime hour incorrect during DST jump forward
When you attempt to set the time to a non-existent time occuring during
a DST jump forward, the hour does not move forward correctly.
-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
@@ -9,6 +9,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 bec60aab6d..d0e14e9f4f 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3562,6 +3562,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 |