com php-src: - Fixed bug #73426: createFromFormat with 'z' format char results in incorrect time.: NEWS ext/date/lib/tm2unixtime.c
ext/date/tests/bug73426.phpt
| From: | Derick Rethans | Date: | Mon, 31 Oct 2016 10:43:33 +0000 |
| Subject: | com php-src: - Fixed bug #73426: createFromFormat with 'z' format char results in incorrect time.: NEWS ext/date/lib/tm2unixtime.c ext/date/tests/bug73426.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95364@lists.php.net to get a copy of this message | ||
Commit: 1d1a7feecfab42bb3a0657ed684e11abeae45315
Author: Derick Rethans <github@derickrethans.nl> Mon, 31 Oct 2016 10:43:33 +0000
Parents: 97fc6aa8df27968ce549cf2dd0b0245f0441e6a3
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1d1a7feecfab42bb3a0657ed684e11abeae45315
Log:
- Fixed bug #73426: createFromFormat with 'z' format char results in incorrect time.
Bugs:
https://bugs.php.net/73426
Changed paths:
M NEWS
M ext/date/lib/tm2unixtime.c
A ext/date/tests/bug73426.phpt
Diff:
diff --git a/NEWS b/NEWS
index cc381e6..bc9945f 100644
--- a/NEWS
+++ b/NEWS
@@ -6,14 +6,18 @@ PHP NEWS
. Fixded bug #72736 (Slow performance when fetching large dataset with mysqli
/ PDO). (Dmitry)
-- PCRE:
- . Fixed bug #73392 (A use-after-free in zend allocator management).
- (Laruence)
+- Date:
+ . Fixed bug #73426 (createFromFormat with 'z' format char results in
+ incorrect time). (Derick)
- JSON:
. Introduced encoder struct instead of global which fixes bugs #66025 and
#73254 related to pretty print indentation. (Jakub Zelenka)
+- PCRE:
+ . Fixed bug #73392 (A use-after-free in zend allocator management).
+ (Laruence)
+
27 Oct 2016, PHP 7.1.0RC5
- Core:
diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c
index 0d65006..d89d6e6 100644
--- a/ext/date/lib/tm2unixtime.c
+++ b/ext/date/lib/tm2unixtime.c
@@ -204,7 +204,7 @@ void timelib_do_rel_normalize(timelib_time *base, timelib_rel_time *rt)
void timelib_do_normalize(timelib_time* time)
{
- if (time->s != TIMELIB_UNSET) do_range_limit_fraction(&time->f, &time->s);
+ if (time->f != TIMELIB_UNSET) do_range_limit_fraction(&time->f, &time->s);
if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i);
if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h);
if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d);
diff --git a/ext/date/tests/bug73426.phpt b/ext/date/tests/bug73426.phpt
new file mode 100644
index 0000000..c2a700a
--- /dev/null
+++ b/ext/date/tests/bug73426.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #73426 (createFromFormat with 'z' format char results in incorrect time)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$date = '12:00:00 15';
+$format = 'H:i:s z';
+var_dump(DateTime::createFromFormat($format, $date));
+
+$date = '16 12:00:00';
+$format = 'z H:i:s';
+var_dump(DateTime::createFromFormat($format, $date));
+
+?>
+--EXPECTF--
+object(DateTime)#%d (%d) {
+ ["date"]=>
+ string(26) "2016-01-16 12:00:00.000000"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
+}
+object(DateTime)#%d (%d) {
+ ["date"]=>
+ string(26) "2016-01-17 12:00:00.000000"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
+}