mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
- MFH: Fixed bug #45529 (new DateTimeZone() and date_create()->getTimezone() behave
different).
This commit is contained in:
parent
44557cf981
commit
0ab7520dc0
@ -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;
|
||||
|
@ -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;
|
||||
|
20
ext/date/tests/bug45529.phpt
Normal file
20
ext/date/tests/bug45529.phpt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user