Edit report at http://bugs.php.net/bug.php?id=44780&edit=1
ID: 44780
Comment by: theogaden at gmail dot com
Reported by: shawn dot parker at alttech dot com
Summary: some time zone offsets not recognized by
timezone_name_from_abbr
Status: Assigned
Type: Bug
Package: Date/time related
Operating System: *
PHP Version: 5CVS-2008-08-14
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
I have the exact same problem and I found this bug entry thanks to
someone at
stackoverflow. Here was my original question:
http://stackoverflow.com/questions/6180892/why-does-timezone-name-from-abbr-
return-an-empty-string
Test Code
------------------------------
$offset = -10; //UM10
echo timezone_name_from_abbr('', $offset * 3600, true); //empty string
Expected Result
------------------------------
Pacific/Honolulu
Actual result:
------------------------------
false
I am using PHP 5.3.0.
Previous Comments:
------------------------------------------------------------------------
[2009-05-08 18:23:40] mfburdett at gmail dot com
I was able to resolve this by changing the fallbackmap from hours to
minutes (the bug is apparently due to some issue with float vs.
integer). Also, this patch adds Caracas and Shanghai time (there are
likely other missing time zones, however) and uses the new spelling for
Calcutta (Kolkata).
Index: ext/date/lib/fallbackmap.h
===================================================================
RCS file: /repository/php-src/ext/date/lib/fallbackmap.h,v
retrieving revision 1.3
diff -u -p -r1.3 fallbackmap.h
--- ext/date/lib/fallbackmap.h 15 Oct 2005 18:14:40 -0000 1.3
+++ ext/date/lib/fallbackmap.h 8 May 2009 18:18:32 -0000
@@ -1,40 +1,42 @@
- { "sst", 0, -11, "Pacific/Apia" },
- { "hst", 0, -10, "Pacific/Honolulu" },
- { "akst", 0, -9, "America/Anchorage" },
- { "akdt", 1, -8, "America/Anchorage" },
- { "pst", 0, -8, "America/Los_Angeles" },
- { "pdt", 1, -7, "America/Los_Angeles" },
- { "mst", 0, -7, "America/Denver" },
- { "mdt", 1, -6, "America/Denver" },
- { "cst", 0, -6, "America/Chicago" },
- { "cdt", 1, -5, "America/Chicago" },
- { "est", 0, -5, "America/New_York" },
- { "edt", 1, -4, "America/New_York" },
- { "ast", 0, -4, "America/Halifax" },
- { "adt", 1, -3, "America/Halifax" },
- { "brt", 0, -3, "America/Sao_Paulo" },
- { "brst", 1, -2, "America/Sao_Paulo" },
- { "azost", 0, -1, "Atlantic/Azores" },
- { "azodt", 1, 0, "Atlantic/Azores" },
- { "gmt", 0, 0, "Europe/London" },
- { "bst", 1, 1, "Europe/London" },
- { "cet", 0, 1, "Europe/Paris" },
- { "cest", 1, 2, "Europe/Paris" },
- { "eet", 0, 2, "Europe/Helsinki" },
- { "eest", 1, 3, "Europe/Helsinki" },
- { "msk", 0, 3, "Europe/Moscow" },
- { "msd", 1, 4, "Europe/Moscow" },
- { "gst", 0, 4, "Asia/Dubai" },
- { "pkt", 0, 5, "Asia/Karachi" },
- { "ist", 0, 5.5, "Asia/Calcutta" },
- { "npt", 0, 5.75, "Asia/Katmandu" },
- { "yekt", 1, 6, "Asia/Yekaterinburg" },
- { "novst", 1, 7, "Asia/Novosibirsk" },
- { "krat", 0, 7, "Asia/Krasnoyarsk" },
- { "krast", 1, 8, "Asia/Krasnoyarsk" },
- { "jst", 0, 9, "Asia/Tokyo" },
- { "est", 0, 10, "Australia/Melbourne" },
- { "cst", 1, 10.5, "Australia/Adelaide" },
- { "est", 1, 11, "Australia/Melbourne" },
- { "nzst", 0, 12, "Pacific/Auckland" },
- { "nzdt", 1, 13, "Pacific/Auckland" },
+ { "sst", 0, -660, "Pacific/Apia" },
+ { "hst", 0, -600, "Pacific/Honolulu" },
+ { "akst", 0, -540, "America/Anchorage" },
+ { "akdt", 1, -480, "America/Anchorage" },
+ { "pst", 0, -480, "America/Los_Angeles" },
+ { "pdt", 1, -420, "America/Los_Angeles" },
+ { "mst", 0, -420, "America/Denver" },
+ { "mdt", 1, -360, "America/Denver" },
+ { "cst", 0, -360, "America/Chicago" },
+ { "cdt", 1, -300, "America/Chicago" },
+ { "est", 0, -300, "America/New_York" },
+ { "vet", 0, -270, "America/Caracas" },
+ { "edt", 1, -240, "America/New_York" },
+ { "ast", 0, -240, "America/Halifax" },
+ { "adt", 1, -180, "America/Halifax" },
+ { "brt", 0, -180, "America/Sao_Paulo" },
+ { "brst", 1, -120, "America/Sao_Paulo" },
+ { "azost", 0, -60, "Atlantic/Azores" },
+ { "azodt", 1, 0, "Atlantic/Azores" },
+ { "gmt", 0, 0, "Europe/London" },
+ { "bst", 1, 60, "Europe/London" },
+ { "cet", 0, 60, "Europe/Paris" },
+ { "cest", 1, 120, "Europe/Paris" },
+ { "eet", 0, 120, "Europe/Helsinki" },
+ { "eest", 1, 180, "Europe/Helsinki" },
+ { "msk", 0, 180, "Europe/Moscow" },
+ { "msd", 1, 240, "Europe/Moscow" },
+ { "gst", 0, 240, "Asia/Dubai" },
+ { "pkt", 0, 300, "Asia/Karachi" },
+ { "ist", 0, 330, "Asia/Kolkata" },
+ { "npt", 0, 345, "Asia/Katmandu" },
+ { "yekt", 1, 360, "Asia/Yekaterinburg" },
+ { "novst", 1, 420, "Asia/Novosibirsk" },
+ { "krat", 0, 420, "Asia/Krasnoyarsk" },
+ { "cst", 0, 480, "Asia/Shanghai" },
+ { "krast", 1, 480, "Asia/Krasnoyarsk" },
+ { "jst", 0, 540, "Asia/Tokyo" },
+ { "est", 0, 600, "Australia/Melbourne" },
+ { "cst", 1, 630, "Australia/Adelaide" },
+ { "est", 1, 660, "Australia/Melbourne" },
+ { "nzst", 0, 720, "Pacific/Auckland" },
+ { "nzdt", 1, 780, "Pacific/Auckland" },
Index: ext/date/lib/parse_date.c
===================================================================
RCS file: /repository/php-src/ext/date/lib/parse_date.c,v
retrieving revision 1.102
diff -u -p -r1.102 parse_date.c
--- ext/date/lib/parse_date.c 10 Mar 2009 23:39:11 -0000 1.102
+++ ext/date/lib/parse_date.c 8 May 2009 18:18:32 -0000
@@ -719,7 +719,7 @@ const static timelib_tz_lookup_table* zo
/* Still didn't find anything, let's find the zone solely based on
* offset/isdst then */
for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) {
- if ((fmp->gmtoffset * 3600) == gmtoffset && fmp->type == isdst)
{
+ if ((fmp->gmtoffset * 60) == gmtoffset && fmp->type == isdst) {
return fmp;
}
}
Index: ext/date/lib/parse_date.re
===================================================================
RCS file: /repository/php-src/ext/date/lib/parse_date.re,v
retrieving revision 1.92
diff -u -p -r1.92 parse_date.re
--- ext/date/lib/parse_date.re 18 Dec 2008 14:54:51 -0000 1.92
+++ ext/date/lib/parse_date.re 8 May 2009 18:18:32 -0000
@@ -717,7 +717,7 @@ const static timelib_tz_lookup_table* zo
/* Still didn't find anything, let's find the zone solely based on
* offset/isdst then */
for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) {
- if ((fmp->gmtoffset * 3600) == gmtoffset && fmp->type == isdst)
{
+ if ((fmp->gmtoffset * 60) == gmtoffset && fmp->type == isdst) {
return fmp;
}
}
------------------------------------------------------------------------
[2008-11-07 18:13:38] mfburdett at gmail dot com
The originally filed reproduce code
var_dump( timezone_name_from_abbr('',-36000,1) );
and expected result 'Pacific/Honolulu' are not actually valid because
Honolulu does not observe daylight saving time. See comments above for
what look like actual bugs.
------------------------------------------------------------------------
[2008-11-07 17:33:44] mfburdett at gmail dot com
The affected population sizes of the two issues may be similar after
all: China standard time is missing from the fallbackmap (offset 8
hours, daylight saving time 0).
------------------------------------------------------------------------
[2008-11-07 17:25:33] mfburdett at gmail dot com
Looking at
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/fallbackmap.h?revision=1.3&view=markup
it appears to be a simple bug: lookups of the fallbackmap are not
working for any of the time zones with non-integer offsets. A more
minor issue (in terms of affected population size) is that some valid
offsets are missing from the fallbackmap.
------------------------------------------------------------------------
[2008-11-06 20:22:31] mfburdett at gmail dot com
Note some of the above abbreviations are obsolete, e.g. BURT has been
replaced with MMT. But the point is timezone_name_from_abbr() does not
work for those offsets without an abbreviation.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=44780
--
Edit this bug report at http://bugs.php.net/bug.php?id=44780&edit=1