Edit report at http://bugs.php.net/bug.php?id=46111&edit=1
ID: 46111 Updated by: [email protected] Reported by: jason at eventshop dot com dot au Summary: strtotime() returns false for some valid timezones -Status: Assigned +Status: Closed Type: Bug Package: Date/time related Operating System: * PHP Version: 5.*, 6CVS (2009-05-10) Assigned To: derick New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2010-03-07 20:18:09] [email protected] Automatic comment from SVN on behalf of derick Revision: http://svn.php.net/viewvc/?view=revision&revision=295940 Log: - Fixed bug #46111 (Some timezone identifiers can not be parsed). ------------------------------------------------------------------------ [2010-01-27 14:10:20] [email protected] Thanks! I should have some time next week to look at your patches (and comments). ------------------------------------------------------------------------ [2010-01-27 12:49:37] yoarvi at gmail dot com Test case: Index: ext/date/tests/bug46111.phpt =================================================================== --- ext/date/tests/bug46111.phpt (revision 0) +++ ext/date/tests/bug46111.phpt (revision 0) @@ -0,0 +1,23 @@ +--TEST-- +Bug #46111 (strtotime() returns false for some valid timezones) +--FILE-- +<?php +date_default_timezone_set('Asia/Calcutta'); +$timezones = timezone_identifiers_list(); + +# An empty list indicates no errors +print "[strtotime(timezone) == false - Begin List]\n"; +foreach ($timezones as $zone) { + $date_string = "2008-01-01 13:00:00 " . $zone; + + if (!strtotime($date_string)) { + echo $zone . "\n"; + } +} +print "[strtotime(timezone) == false - End List]\n"; +?> +--EXPECT-- +[strtotime(timezone) == false - Begin List] +[strtotime(timezone) == false - End List] + ------------------------------------------------------------------------ [2010-01-21 14:00:59] yoarvi at gmail dot com The failures in PHP 5.3 are the following: Africa/Dar_es_Salaam Africa/Porto-Novo America/Blanc-Sablon America/Port-au-Prince America/Port_of_Spain Antarctica/DumontDUrville Antarctica/McMurdo The regex for tz in parse_date.re doesn't account for hyphens, or for lower-case following an _ or for consecutive upper case letters. Applying the following patch and regenerating parse_date.c fixes the problem: Index: ext/date/lib/parse_date.re =================================================================== --- ext/date/lib/parse_date.re (revision 293574) +++ ext/date/lib/parse_date.re (working copy) @@ -854,7 +854,7 @@ second = minute | "60"; secondlz = minutelz | "60"; meridian = ([AaPp] "."? [Mm] "."?) [\000\t ]; -tz = "("? [A-Za-z]{1,6} ")"? | [A-Z][a-z]+([_/][A-Z][a-z]+)+; +tz = "("? [A-Za-z]{1,6} ")"? | [A-Z][a-z]+([_/-][A-Za-z]+)+; tzcorrection = "GMT"? [+-] hour24 ":"? minute?; daysuf = "st" | "nd" | "rd" | "th"; ------------------------------------------------------------------------ [2009-05-10 21:19:37] [email protected] The list is a bit shorter with PHP_5_3 than with PHP_5_2..some progress? :) ------------------------------------------------------------------------ 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=46111 -- Edit this bug report at http://bugs.php.net/bug.php?id=46111&edit=1
