Skip to content

Commit 1d9e716

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79396: DateTime hour incorrect during DST jump forward
2 parents 280485a + d70058a commit 1d9e716

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
- CURL:
1111
. Fixed bug #79199 (curl_copy_handle() memory leak). (cmb)
1212

13+
- Date:
14+
. Fixed bug #79396 (DateTime hour incorrect during DST jump forward). (Nate
15+
Brunette)
16+
1317
- SimpleXML:
1418
. Fixed bug #61597 (SXE properties may lack attributes and content). (cmb)
1519

ext/date/php_date.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3573,6 +3573,7 @@ static void php_date_time_set(zval *object, zend_long h, zend_long i, zend_long
35733573
dateobj->time->s = s;
35743574
dateobj->time->us = ms;
35753575
timelib_update_ts(dateobj->time, NULL);
3576+
timelib_update_from_sse(dateobj->time);
35763577
} /* }}} */
35773578

35783579
/* {{{ proto DateTime date_time_set(DateTime object, int hour, int minute[, int second[, int microseconds]])
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test for setting Date/Time during a forward DST transition
3+
--FILE--
4+
<?php
5+
date_default_timezone_set('America/Chicago');
6+
7+
$date = new DateTime('2020-03-08 01:30:00');
8+
echo $date->setTime(2, 0)->format('Y-m-d H:i:s T/e - U') . "\n";
9+
10+
$date = new DateTime('2020-03-08 01:30:00');
11+
echo $date->setTime(2, 30)->format('Y-m-d H:i:s T/e - U') . "\n";
12+
13+
$date = new DateTime('2020-03-08 01:30:00');
14+
echo $date->setTime(3, 0)->format('Y-m-d H:i:s T/e - U') . "\n";
15+
16+
$date = new DateTime('2020-03-08 01:30:00');
17+
echo $date->setTime(1, 59, 59)->format('Y-m-d H:i:s T/e - U') . "\n";
18+
19+
?>
20+
--EXPECT--
21+
2020-03-08 03:00:00 CDT/America/Chicago - 1583654400
22+
2020-03-08 03:30:00 CDT/America/Chicago - 1583656200
23+
2020-03-08 03:00:00 CDT/America/Chicago - 1583654400
24+
2020-03-08 01:59:59 CST/America/Chicago - 1583654399

0 commit comments

Comments
 (0)