Skip to content

Commit d12ba11

Browse files
committed
Fixed GH-10218: DateTimeZone fails to parse time zones that contain the "+" character
1 parent a9e7b90 commit d12ba11

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ PHP NEWS
1313
- Date:
1414
. Fixed bug GH-9891 (DateTime modify with unixtimestamp (@) must work like
1515
setTimestamp). (Derick)
16+
. Fixed bug GH-10218 (DateTimeZone fails to parse time zones that contain the
17+
"+" character). (Derick)
1618

1719
- FPM:
1820
. Fixed bug GH-9981 (FPM does not reset fastcgi.error_header).

ext/date/lib/parse_date.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by re2c 0.15.3 on Thu Dec 1 10:57:42 2022 */
1+
/* Generated by re2c 0.15.3 on Tue Jan 10 15:14:08 2023 */
22
#line 1 "ext/date/lib/parse_date.re"
33
/*
44
* The MIT License (MIT)
@@ -761,7 +761,7 @@ static timelib_long timelib_lookup_abbr(const char **ptr, int *dst, char **tz_ab
761761
(**ptr >= 'A' && **ptr <= 'Z') ||
762762
(**ptr >= 'a' && **ptr <= 'z') ||
763763
(**ptr >= '0' && **ptr <= '9') ||
764-
**ptr == '/' || **ptr == '_' || **ptr == '-'
764+
**ptr == '/' || **ptr == '_' || **ptr == '-' || **ptr == '+'
765765
) {
766766
++*ptr;
767767
}

ext/date/lib/parse_date.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ static timelib_long timelib_lookup_abbr(const char **ptr, int *dst, char **tz_ab
759759
(**ptr >= 'A' && **ptr <= 'Z') ||
760760
(**ptr >= 'a' && **ptr <= 'z') ||
761761
(**ptr >= '0' && **ptr <= '9') ||
762-
**ptr == '/' || **ptr == '_' || **ptr == '-'
762+
**ptr == '/' || **ptr == '_' || **ptr == '-' || **ptr == '+'
763763
) {
764764
++*ptr;
765765
}

ext/date/tests/gh10218.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug GH-10218 (DateTimeZone fails to parse time zones that contain the "+" character)
3+
--FILE--
4+
<?php
5+
var_dump(new DateTime('now', new DateTimeZone('Etc/GMT+1')));
6+
?>
7+
--EXPECTF--
8+
object(DateTime)#%d (%d) {
9+
["date"]=>
10+
string(%d) "%s"
11+
["timezone_type"]=>
12+
int(3)
13+
["timezone"]=>
14+
string(9) "Etc/GMT+1"
15+
}

0 commit comments

Comments
 (0)