]> granicus.if.org Git - php/commitdiff
- MFH: Fixed bug #45529 (new DateTimeZone() and date_create()->getTimezone() behave
authorDerick Rethans <derick@php.net>
Wed, 16 Jul 2008 15:41:01 +0000 (15:41 +0000)
committerDerick Rethans <derick@php.net>
Wed, 16 Jul 2008 15:41:01 +0000 (15:41 +0000)
  different).

ext/date/lib/parse_date.c
ext/date/lib/parse_date.re
ext/date/tests/bug45529.phpt [new file with mode: 0644]

index dd0984c8b6e177e1f7d5b1e6debacb3d763c1f1a..e08a794497c9d5c3a4e02d2b4e1582b4bf274645 100644 (file)
@@ -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;
index 14bd7e88db4a737daddbccf39e44ee4b01cf463d..2a66d51461cddbe1887e5e9df948025e487e1f85 100644 (file)
@@ -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 (file)
index 0000000..ce4bca9
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Bug #45529 (UTC not properly recognised as timezone identifier while parsing)
+--FILE--
+<?php
+$tz1 = new DateTimeZone('UTC');
+$tz2 = date_create('UTC')->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