From: Derick Rethans Date: Wed, 16 Jul 2008 15:41:01 +0000 (+0000) Subject: - MFH: Fixed bug #45529 (new DateTimeZone() and date_create()->getTimezone() behave X-Git-Tag: php-5.3.0alpha1~319 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ab7520dc0b05a50ff604c2d8d330a7880eccc07;p=php - MFH: Fixed bug #45529 (new DateTimeZone() and date_create()->getTimezone() behave different). --- diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index dd0984c8b6..e08a794497 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Tue Jul 15 19:21:36 2008 */ +/* Generated by re2c 0.13.5 on Wed Jul 16 17:24:19 2008 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -800,7 +800,7 @@ static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_ } #endif /* If we have a TimeZone identifier to start with, use it */ - if (strstr(tz_abbr, "/")) { + if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) { if ((res = timelib_parse_tzfile(tz_abbr, tzdb)) != NULL) { t->tz_info = res; t->zone_type = TIMELIB_ZONETYPE_ID; diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 14bd7e88db..2a66d51461 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -798,7 +798,7 @@ static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_ } #endif /* If we have a TimeZone identifier to start with, use it */ - if (strstr(tz_abbr, "/")) { + if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) { if ((res = timelib_parse_tzfile(tz_abbr, tzdb)) != NULL) { t->tz_info = res; t->zone_type = TIMELIB_ZONETYPE_ID; diff --git a/ext/date/tests/bug45529.phpt b/ext/date/tests/bug45529.phpt new file mode 100644 index 0000000000..ce4bca96b3 --- /dev/null +++ b/ext/date/tests/bug45529.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #45529 (UTC not properly recognised as timezone identifier while parsing) +--FILE-- +getTimeZone(); +echo $tz1->getName(), PHP_EOL; +echo $tz2->getName(), PHP_EOL; +$d = new DateTime('2008-01-01 12:00:00+0200'); +$d->setTimeZone($tz1); +echo $d->format(DATE_ISO8601), PHP_EOL; +$d = new DateTime('2008-01-01 12:00:00+0200'); +$d->setTimeZone($tz2); +echo $d->format(DATE_ISO8601), PHP_EOL; +?> +--EXPECT-- +UTC +UTC +2008-01-01T10:00:00+0000 +2008-01-01T10:00:00+0000