derick Sat Oct 1 11:04:08 2005 EDT Added files: (Branch: PHP_5_1) /php-src/ext/date/lib fallbackmap.h timezonemap.h
Modified files: /php-src/ext/date php_date.c /php-src/ext/date/lib .cvsignore parse_date.c timelib.h timelib_structs.h /php-src/ext/date/lib/resource parse_date.re /php-src/ext/date/tests date_default_timezone_get-1.phpt date_default_timezone_set-1.phpt Log: - Implemented better timezone guessing algorithm.
http://cvs.php.net/diff.php/php-src/ext/date/php_date.c?r1=1.43.2.5&r2=1.43.2.6&ty=u Index: php-src/ext/date/php_date.c diff -u php-src/ext/date/php_date.c:1.43.2.5 php-src/ext/date/php_date.c:1.43.2.6 --- php-src/ext/date/php_date.c:1.43.2.5 Fri Sep 2 10:58:01 2005 +++ php-src/ext/date/php_date.c Sat Oct 1 11:04:02 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_date.c,v 1.43.2.5 2005/09/02 14:58:01 derick Exp $ */ +/* $Id: php_date.c,v 1.43.2.6 2005/10/01 15:04:02 derick Exp $ */ #include "php.h" #include "php_streams.h" @@ -265,7 +265,7 @@ } /* Check environment variable */ env = getenv("TZ"); - if (env && *env) { + if (env && *env && strlen(env)) { return env; } /* Check config setting for default timezone */ @@ -281,12 +281,12 @@ the_time = time(NULL); ta = php_localtime_r(&the_time, &tmbuf); - tzid = timelib_timezone_id_from_abbr(ta->tm_zone); + tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst); if (! tzid) { tzid = "UTC"; } - php_error_docref(NULL TSRMLS_CC, E_STRICT, "It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use '%s' for '%s' instead.", tzid, ta->tm_zone); + php_error_docref(NULL TSRMLS_CC, E_STRICT, "It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use '%s' for '%s/%.1f/%s' instead.", tzid, ta->tm_zone, (float) (ta->tm_gmtoff / 3600), ta->tm_isdst ? "DST" : "no DST"); return tzid; } #endif @@ -1228,7 +1228,7 @@ if (!tzi) { char *tzid; - tzid = timelib_timezone_id_from_abbr(tz); + tzid = timelib_timezone_id_from_abbr(tz, -1, 0); if (tzid) { tzi = timelib_parse_tzfile(tzid); } @@ -1325,12 +1325,12 @@ table = timelib_timezone_abbreviations_list(); array_init(return_value); entry = table; - +#warning NEED TO MAKE SURE ABBRS ARE NOT UNIQUEIZED HERE do { MAKE_STD_ZVAL(element); array_init(element); add_assoc_bool(element, "dst", entry->type); - add_assoc_long(element, "offset", - entry->value * 60); + add_assoc_long(element, "offset", entry->gmtoffset); if (entry->full_tz_name) { add_assoc_string(element, "timezone_id", entry->full_tz_name, 1); } else { http://cvs.php.net/diff.php/php-src/ext/date/lib/.cvsignore?r1=1.4&r2=1.4.2.1&ty=u Index: php-src/ext/date/lib/.cvsignore diff -u php-src/ext/date/lib/.cvsignore:1.4 php-src/ext/date/lib/.cvsignore:1.4.2.1 --- php-src/ext/date/lib/.cvsignore:1.4 Fri Jun 17 08:03:03 2005 +++ php-src/ext/date/lib/.cvsignore Sat Oct 1 11:04:03 2005 @@ -1,3 +1,10 @@ +parse_date.c +tester-create-ts +tester-parse-string +tester-parse-tz +tester-render-ts +tester-iso-week +*.swp Makefile *.lo *.la http://cvs.php.net/diff.php/php-src/ext/date/lib/parse_date.c?r1=1.29.2.3&r2=1.29.2.4&ty=u Index: php-src/ext/date/lib/parse_date.c diff -u php-src/ext/date/lib/parse_date.c:1.29.2.3 php-src/ext/date/lib/parse_date.c:1.29.2.4 --- php-src/ext/date/lib/parse_date.c:1.29.2.3 Thu Aug 25 05:47:26 2005 +++ php-src/ext/date/lib/parse_date.c Sat Oct 1 11:04:03 2005 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.10.dev on Thu Aug 25 11:33:54 2005 */ +/* Generated by re2c 0.9.10.dev on Sat Oct 1 16:59:40 2005 */ #line 1 "resource/parse_date.re" /* +----------------------------------------------------------------------+ @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: parse_date.c,v 1.29.2.3 2005/08/25 09:47:26 derick Exp $ */ +/* $Id: parse_date.c,v 1.29.2.4 2005/10/01 15:04:03 derick Exp $ */ #include "timelib.h" @@ -162,108 +162,13 @@ /* The timezone table. */ static timelib_tz_lookup_table timelib_timezone_lookup[] = { - { "a", 0, HOUR (- 1), NULL }, - { "adt", 1, HOUR ( 4), "America/Halifax" }, /* Atlantic Daylight */ - { "ahst", 0, HOUR ( 10), "America/Anchorage" }, /* Alaska-Hawaii Standard */ - { "akdt", 0, HOUR ( 10), "America/Anchorage" }, /* Alaska Daylight */ - { "akst", 0, HOUR ( 10), "America/Anchorage" }, /* Alaska Standard */ - { "ast", 0, HOUR ( 4), "America/Halifax" }, /* Atlantic Standard */ - { "at", 0, HOUR ( 2), "Atlantic/Azores" }, /* Azores */ - { "b", 0, HOUR (- 2), NULL }, - { "bst", 1, HOUR ( 0), "Europe/London" }, /* British Summer */ - { "bt", 0, -HOUR ( 3), "Asia/Baghdad" }, /* Baghdad, USSR Zone 2 */ - { "c", 0, HOUR (- 3), NULL }, - { "cadt", 1, -HOUR (9.5), "Australia/Adelaide" }, /* Central Australian Daylight */ - { "cast", 0, -HOUR (9.5), "Australia/Adelaide" }, /* Central Australian Standard */ - { "cat", 0, HOUR ( 10), "America/Anchorage" }, /* Central Alaska */ - { "cct", 0, -HOUR ( 8), "Asia/Shanghai" }, /* China Coast, USSR Zone 7 */ - { "cdt", 1, HOUR ( 6), "America/Chicago" }, /* Central Daylight */ - { "cest", 1, -HOUR ( 1), "Europe/Berlin" }, /* Central European Summer */ - { "cet", 0, -HOUR ( 1), "Europe/Berlin" }, /* Central European */ - { "cst", 0, HOUR ( 6), "America/Chicago" }, /* Central Standard */ - { "d", 0, HOUR (- 4), NULL }, - { "e", 0, HOUR (- 5), NULL }, - { "eadt", 1, -HOUR ( 10), "Australia/Sydney" }, /* Eastern Australian Daylight */ - { "east", 0, -HOUR ( 10), "Australia/Sydney" }, /* Eastern Australian Standard */ - { "edt", 1, HOUR ( 5), "America/New_York" }, /* Eastern Daylight */ - { "eest", 1, HOUR ( 2), "Europe/Helsinki" }, /* Eastern European Summer */ - { "eet", 0, -HOUR ( 2), "Europe/Bucharest" }, /* Eastern Europe, USSR Zone 1 */ - { "est", 0, HOUR ( 5), "America/New_York" }, /* Eastern Standard */ - { "f", 0, HOUR (- 6), NULL }, - { "fst", 1, -HOUR ( 1), "Europe/Paris" }, /* French Summer */ - { "fwt", 0, -HOUR ( 1), "Europe/Paris" }, /* French Winter */ - { "g", 0, HOUR (- 7), NULL }, - { "gmt", 0, HOUR ( 0), "GMT" }, /* Greenwich Mean */ - { "gst", 0, -HOUR ( 10), "Pacific/Guam" }, /* Guam Standard, USSR Zone 9 */ - { "h", 0, HOUR (- 8), NULL }, - { "hdt", 1, HOUR ( 10), "Pacific/Honolulu" }, /* Hawaii Daylight */ - { "hst", 0, HOUR ( 10), "Pacific/Honolulu" }, /* Hawaii Standard */ - { "i", 0, HOUR (- 9), NULL }, - { "idle", 0, -HOUR ( 12), "NZ" }, /* International Date Line East */ - { "idlw", 0, HOUR ( 12), NULL }, /* International Date Line West */ - { "ist", 0, -HOUR (5.5), "Asia/Calcutta" }, /* Indian Standard */ - { "it", 0, -HOUR (3.5), "Asia/Tehran" }, /* Iran */ - { "jst", 0, -HOUR ( 9), "Asia/Tokyo" }, /* Japan Standard, USSR Zone 8 */ - { "jt", 0, -HOUR (7.5), NULL }, /* Java (3pm in Cronusland!) */ - { "k", 0, HOUR (-10), NULL }, - { "l", 0, HOUR (-11), NULL }, - { "m", 0, HOUR (-12), NULL }, - { "mdt", 1, HOUR ( 7), "America/Phoenix" }, /* Mountain Daylight */ - { "mest", 1, -HOUR ( 1), "MET" }, /* Middle European Summer */ - { "mesz", 1, -HOUR ( 1), "MET" }, /* Middle European Summer */ - { "met", 0, -HOUR ( 1), "MET" }, /* Middle European */ - { "mewt", 0, -HOUR ( 1), "MET" }, /* Middle European Winter */ - { "msd", 1, HOUR ( 3), "Europe/Moscow" }, /* Moscow Summer */ - { "msk", 0, HOUR ( 3), "Europe/Moscow" }, /* Moscow */ - { "mst", 0, HOUR ( 7), "America/Phoenix" }, /* Mountain Standard */ - { "n", 0, HOUR ( 1), NULL }, - { "ndt", 1, HOUR (3.5), "America/St_Johns" }, /* Newfoundland Daylight */ - { "nft", 0, HOUR (3.5), "America/St_Johns" }, /* Newfoundland */ - { "nst", 0, HOUR (3.5), "America/St_Johns" }, /* Newfoundland Standard */ - { "nt", 0, HOUR ( 11), NULL }, /* Nome */ - { "nzdt", 1, -HOUR ( 12), "NZ" }, /* New Zealand Daylight */ - { "nzst", 0, -HOUR ( 12), "NZ" }, /* New Zealand Standard */ - { "nzt", 0, -HOUR ( 12), "NZ" }, /* New Zealand */ - { "o", 0, HOUR ( 2), NULL }, - { "p", 0, HOUR ( 3), NULL }, - { "pdt", 1, HOUR ( 8), "America/Los_Angeles" }, /* Pacific Daylight */ - { "pst", 0, HOUR ( 8), "America/Los_Angeles" }, /* Pacific Standard */ - { "q", 0, HOUR ( 4), NULL }, - { "r", 0, HOUR ( 5), NULL }, - { "s", 0, HOUR ( 6), NULL }, - { "slst", 1, -HOUR ( 1), "Europe/Oslo" }, /* Skien Local Summer Time */ - { "slt", 0, -HOUR ( 1), "Europe/Oslo" }, /* Skien Local Time */ - { "sst", 1, -HOUR ( 1), "Europe/Stockholm" }, /* Swedish Summer */ - { "swt", 0, -HOUR ( 1), "Europe/Stockholm" }, /* Swedish Winter */ - { "t", 0, HOUR ( 7), NULL }, - { "u", 0, HOUR ( 8), NULL }, - { "ut", 0, HOUR ( 0), "UTC" }, /* Universal (Coordinated) */ - { "utc", 0, HOUR ( 0), "UTC" }, - { "v", 0, HOUR ( 9), NULL }, - { "w", 0, HOUR ( 10), NULL }, - { "wadt", 1, -HOUR ( 7), "Australia/Perth" }, /* West Australian Daylight */ - { "wast", 0, -HOUR ( 7), "Australia/Perth" }, /* West Australian Standard */ - { "wat", 0, HOUR ( 1), "Africa/Dakar" }, /* West Africa */ - { "wet", 0, HOUR ( 0), "Europe/London" }, /* Western European */ - { "x", 0, HOUR ( 11), NULL }, - { "y", 0, HOUR ( 12), NULL }, - { "ydt", 1, HOUR ( 9), "America/Anchorage" }, /* Yukon Daylight */ - { "yst", 0, HOUR ( 9), "America/Anchorage" }, /* Yukon Standard */ - { "z", 0, HOUR ( 0), NULL }, - { "zp4", 0, -HOUR ( 4), NULL }, /* USSR Zone 3 */ - { "zp5", 0, -HOUR ( 5), NULL }, /* USSR Zone 4 */ - { "zp6", 0, -HOUR ( 6), NULL }, /* USSR Zone 5 */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", 0, HOUR ( 3), NULL }, /* Brazil Standard */ - { "gst", 0, HOUR ( 3), NULL }, /* Greenland Standard */ - - /* For completeness. NST is also Newfoundland Standard, and SST is - * also Swedish Summer. */ - { "nst", 0, -HOUR (6.5), NULL },/* North Sumatra */ - { "sst", 0, -HOUR (7), NULL }, /* South Sumatra, USSR Zone 6 */ -#endif +#include "timezonemap.h" + { NULL, 0, 0, NULL }, +}; + +static timelib_tz_lookup_table timelib_timezone_fallbackmap[] = { +#include "fallbackmap.h" + { NULL, 0, 0, NULL }, }; static timelib_relunit const timelib_relunit_lookup[] = { @@ -652,24 +557,37 @@ } } -static timelib_tz_lookup_table* zone_search(const char *word, int left, int right) +static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffset, int isdst) { - int mid, cmp; - - if (left > right) { - return NULL; /* not found */ + int first_found = 0; + timelib_tz_lookup_table *tp, *first_found_elem; + timelib_tz_lookup_table *fmp; + + for (tp = timelib_timezone_lookup; tp->name; tp++) { + if (strcasecmp(word, tp->name) == 0) { + if (!first_found) { + first_found = 1; + first_found_elem = tp; + if (gmtoffset == -1) { + return tp; + } + } + if (tp->gmtoffset == gmtoffset) { + return tp; + } + } + } + if (first_found) { + return first_found_elem; } - - mid = (left + right) / 2; - - cmp = strcasecmp(word, timelib_timezone_lookup[mid].name); - if (cmp < 0) { - return zone_search(word, left, mid - 1); - } else if (cmp > 0) { - return zone_search(word, mid + 1, right); - } else { /* (cmp == 0) */ - return (timelib_tz_lookup_table*)&timelib_timezone_lookup[mid]; + /* 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) { + return fmp; + } } + return NULL; } static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found) @@ -686,9 +604,10 @@ word = calloc(1, end - begin + 1); memcpy(word, begin, end - begin); - if ((tp = zone_search(word, 0, sizeof(timelib_timezone_lookup)/sizeof(*timelib_timezone_lookup)-1))) { - value = tp->value; + if ((tp = zone_search(word, -1, 0))) { + value = -tp->gmtoffset / 60; *dst = tp->type; + value += tp->type * 60; *found = 1; } else { *found = 0; @@ -773,7 +692,7 @@ std: s->tok = cursor; s->len = 0; -#line 879 "resource/parse_date.re" +#line 798 "resource/parse_date.re" { @@ -812,7 +731,7 @@ 0, 0, 0, 0, 0, 0, 0, 0, }; -#line 816 "<stdout>" +#line 735 "<stdout>" { YYCTYPE yych; unsigned int yyaccept; @@ -897,7 +816,7 @@ yy3: YYDEBUG(3, *YYCURSOR); -#line 1361 "resource/parse_date.re" +#line 1280 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("tzcorrection | tz"); @@ -907,7 +826,7 @@ TIMELIB_DEINIT; return TIMELIB_TIMEZONE; } -#line 904 "<stdout>" +#line 823 "<stdout>" yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; @@ -993,13 +912,13 @@ yy7: YYDEBUG(7, *YYCURSOR); -#line 1427 "resource/parse_date.re" +#line 1346 "resource/parse_date.re" { /* printf("unexpected character: #%d, %c ", *s->tok, *s->tok); */ s->errors++; goto std; } -#line 987 "<stdout>" +#line 906 "<stdout>" yy8: YYDEBUG(8, *YYCURSOR); yyaccept = 0; @@ -1922,11 +1841,11 @@ yy44: YYDEBUG(44, *YYCURSOR); -#line 1416 "resource/parse_date.re" +#line 1335 "resource/parse_date.re" { goto std; } -#line 1835 "<stdout>" +#line 1754 "<stdout>" yy45: YYDEBUG(45, *YYCURSOR); ++YYCURSOR; @@ -1934,12 +1853,12 @@ yy46: YYDEBUG(46, *YYCURSOR); -#line 1421 "resource/parse_date.re" +#line 1340 "resource/parse_date.re" { s->pos = cursor; s->line++; goto std; } -#line 1844 "<stdout>" +#line 1763 "<stdout>" yy47: YYDEBUG(47, *YYCURSOR); yych = *++YYCURSOR; @@ -2397,7 +2316,7 @@ yy85: YYDEBUG(85, *YYCURSOR); -#line 1400 "resource/parse_date.re" +#line 1319 "resource/parse_date.re" { timelib_ull i; DEBUG_OUTPUT("relative"); @@ -2412,7 +2331,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 2234 "<stdout>" +#line 2153 "<stdout>" yy86: YYDEBUG(86, *YYCURSOR); ++YYCURSOR; @@ -3105,12 +3024,12 @@ yy151: YYDEBUG(151, *YYCURSOR); -#line 1355 "resource/parse_date.re" +#line 1274 "resource/parse_date.re" { DEBUG_OUTPUT("dayabbr"); goto std; } -#line 2798 "<stdout>" +#line 2717 "<stdout>" yy152: YYDEBUG(152, *YYCURSOR); yyaccept = 1; @@ -3149,7 +3068,7 @@ yy158: YYDEBUG(158, *YYCURSOR); -#line 1339 "resource/parse_date.re" +#line 1258 "resource/parse_date.re" { const timelib_relunit* relunit; DEBUG_OUTPUT("dayfull"); @@ -3164,7 +3083,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 2838 "<stdout>" +#line 2757 "<stdout>" yy159: YYDEBUG(159, *YYCURSOR); yyaccept = 1; @@ -3533,7 +3452,7 @@ yy190: YYDEBUG(190, *YYCURSOR); -#line 1323 "resource/parse_date.re" +#line 1242 "resource/parse_date.re" { timelib_sll i; DEBUG_OUTPUT("relativetext"); @@ -3548,7 +3467,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 3156 "<stdout>" +#line 3075 "<stdout>" yy191: YYDEBUG(191, *YYCURSOR); ++YYCURSOR; @@ -9178,7 +9097,7 @@ yy509: YYDEBUG(509, *YYCURSOR); -#line 1145 "resource/parse_date.re" +#line 1064 "resource/parse_date.re" { DEBUG_OUTPUT("datetextual | datenoyear"); TIMELIB_INIT; @@ -9190,7 +9109,7 @@ TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 8149 "<stdout>" +#line 8068 "<stdout>" yy510: YYDEBUG(510, *YYCURSOR); yych = *++YYCURSOR; @@ -9350,7 +9269,7 @@ yy527: YYDEBUG(527, *YYCURSOR); -#line 1372 "resource/parse_date.re" +#line 1291 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz"); @@ -9377,7 +9296,7 @@ TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 8300 "<stdout>" +#line 8219 "<stdout>" yy528: YYDEBUG(528, *YYCURSOR); yyaccept = 7; @@ -9690,7 +9609,7 @@ yy562: YYDEBUG(562, *YYCURSOR); -#line 1119 "resource/parse_date.re" +#line 1038 "resource/parse_date.re" { DEBUG_OUTPUT("datenoday"); TIMELIB_INIT; @@ -9702,7 +9621,7 @@ TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 8555 "<stdout>" +#line 8474 "<stdout>" yy563: YYDEBUG(563, *YYCURSOR); yyaccept = 6; @@ -10002,7 +9921,7 @@ yy588: YYDEBUG(588, *YYCURSOR); -#line 1254 "resource/parse_date.re" +#line 1173 "resource/parse_date.re" { DEBUG_OUTPUT("pgtextshort"); TIMELIB_INIT; @@ -10014,7 +9933,7 @@ TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 8814 "<stdout>" +#line 8733 "<stdout>" yy589: YYDEBUG(589, *YYCURSOR); yych = *++YYCURSOR; @@ -11518,7 +11437,7 @@ yy684: YYDEBUG(684, *YYCURSOR); -#line 1308 "resource/parse_date.re" +#line 1227 "resource/parse_date.re" { DEBUG_OUTPUT("ago"); TIMELIB_INIT; @@ -11532,7 +11451,7 @@ TIMELIB_DEINIT; return TIMELIB_AGO; } -#line 10139 "<stdout>" +#line 10058 "<stdout>" yy685: YYDEBUG(685, *YYCURSOR); yyaccept = 1; @@ -13466,7 +13385,7 @@ yy788: YYDEBUG(788, *YYCURSOR); -#line 1158 "resource/parse_date.re" +#line 1077 "resource/parse_date.re" { DEBUG_OUTPUT("datenoyearrev"); TIMELIB_INIT; @@ -13476,7 +13395,7 @@ TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 11871 "<stdout>" +#line 11790 "<stdout>" yy789: YYDEBUG(789, *YYCURSOR); yyaccept = 10; @@ -13569,7 +13488,7 @@ yy797: YYDEBUG(797, *YYCURSOR); -#line 966 "resource/parse_date.re" +#line 885 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long"); @@ -13592,7 +13511,7 @@ TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 11969 "<stdout>" +#line 11888 "<stdout>" yy798: YYDEBUG(798, *YYCURSOR); yyaccept = 11; @@ -13720,7 +13639,7 @@ yy812: YYDEBUG(812, *YYCURSOR); -#line 951 "resource/parse_date.re" +#line 870 "resource/parse_date.re" { DEBUG_OUTPUT("timeshort12 | timelong12"); TIMELIB_INIT; @@ -13734,7 +13653,7 @@ TIMELIB_DEINIT; return TIMELIB_TIME12; } -#line 12081 "<stdout>" +#line 12000 "<stdout>" yy813: YYDEBUG(813, *YYCURSOR); yych = *++YYCURSOR; @@ -13857,7 +13776,7 @@ yy825: YYDEBUG(825, *YYCURSOR); -#line 1093 "resource/parse_date.re" +#line 1012 "resource/parse_date.re" { DEBUG_OUTPUT("datefull"); TIMELIB_INIT; @@ -13869,7 +13788,7 @@ TIMELIB_DEINIT; return TIMELIB_DATE_FULL; } -#line 12190 "<stdout>" +#line 12109 "<stdout>" yy826: YYDEBUG(826, *YYCURSOR); yych = *++YYCURSOR; @@ -14488,7 +14407,7 @@ yy893: YYDEBUG(893, *YYCURSOR); -#line 1106 "resource/parse_date.re" +#line 1025 "resource/parse_date.re" { DEBUG_OUTPUT("pointed date"); TIMELIB_INIT; @@ -14500,7 +14419,7 @@ TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 12685 "<stdout>" +#line 12604 "<stdout>" yy894: YYDEBUG(894, *YYCURSOR); yych = *++YYCURSOR; @@ -15068,7 +14987,7 @@ yy939: YYDEBUG(939, *YYCURSOR); -#line 1080 "resource/parse_date.re" +#line 999 "resource/parse_date.re" { DEBUG_OUTPUT("gnudateshort"); TIMELIB_INIT; @@ -15080,7 +14999,7 @@ TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 13173 "<stdout>" +#line 13092 "<stdout>" yy940: YYDEBUG(940, *YYCURSOR); yych = *++YYCURSOR; @@ -15102,7 +15021,7 @@ yy943: YYDEBUG(943, *YYCURSOR); -#line 1053 "resource/parse_date.re" +#line 972 "resource/parse_date.re" { DEBUG_OUTPUT("americanshort | american"); TIMELIB_INIT; @@ -15116,7 +15035,7 @@ TIMELIB_DEINIT; return TIMELIB_AMERICAN; } -#line 13201 "<stdout>" +#line 13120 "<stdout>" yy944: YYDEBUG(944, *YYCURSOR); yyaccept = 12; @@ -15338,7 +15257,7 @@ yy976: YYDEBUG(976, *YYCURSOR); -#line 1280 "resource/parse_date.re" +#line 1199 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("clf"); @@ -15356,7 +15275,7 @@ TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 13375 "<stdout>" +#line 13294 "<stdout>" yy977: YYDEBUG(977, *YYCURSOR); yyaccept = 13; @@ -15665,7 +15584,7 @@ yy1016: YYDEBUG(1016, *YYCURSOR); -#line 1267 "resource/parse_date.re" +#line 1186 "resource/parse_date.re" { DEBUG_OUTPUT("pgtextreverse"); TIMELIB_INIT; @@ -15677,7 +15596,7 @@ TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 13615 "<stdout>" +#line 13534 "<stdout>" yy1017: YYDEBUG(1017, *YYCURSOR); yych = *++YYCURSOR; @@ -15810,7 +15729,7 @@ yy1028: YYDEBUG(1028, *YYCURSOR); -#line 1299 "resource/parse_date.re" +#line 1218 "resource/parse_date.re" { DEBUG_OUTPUT("year4"); TIMELIB_INIT; @@ -15818,7 +15737,7 @@ TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 13731 "<stdout>" +#line 13650 "<stdout>" yy1029: YYDEBUG(1029, *YYCURSOR); yych = *++YYCURSOR; @@ -15954,7 +15873,7 @@ yy1037: YYDEBUG(1037, *YYCURSOR); -#line 1132 "resource/parse_date.re" +#line 1051 "resource/parse_date.re" { DEBUG_OUTPUT("datenodayrev"); TIMELIB_INIT; @@ -15966,7 +15885,7 @@ TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 13858 "<stdout>" +#line 13777 "<stdout>" yy1038: YYDEBUG(1038, *YYCURSOR); yych = *++YYCURSOR; @@ -16175,7 +16094,7 @@ yy1057: YYDEBUG(1057, *YYCURSOR); -#line 1235 "resource/parse_date.re" +#line 1154 "resource/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweek"); @@ -16193,7 +16112,7 @@ TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 14045 "<stdout>" +#line 13964 "<stdout>" yy1058: YYDEBUG(1058, *YYCURSOR); ++YYCURSOR; @@ -16201,7 +16120,7 @@ yy1059: YYDEBUG(1059, *YYCURSOR); -#line 1216 "resource/parse_date.re" +#line 1135 "resource/parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweekday"); @@ -16219,7 +16138,7 @@ TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 14067 "<stdout>" +#line 13986 "<stdout>" yy1060: YYDEBUG(1060, *YYCURSOR); yych = *++YYCURSOR; @@ -16288,7 +16207,7 @@ yy1063: YYDEBUG(1063, *YYCURSOR); -#line 1203 "resource/parse_date.re" +#line 1122 "resource/parse_date.re" { DEBUG_OUTPUT("pgydotd"); TIMELIB_INIT; @@ -16300,7 +16219,7 @@ TIMELIB_DEINIT; return TIMELIB_PG_YEARDAY; } -#line 14140 "<stdout>" +#line 14059 "<stdout>" yy1064: YYDEBUG(1064, *YYCURSOR); yych = *++YYCURSOR; @@ -16415,7 +16334,7 @@ yy1070: YYDEBUG(1070, *YYCURSOR); -#line 1169 "resource/parse_date.re" +#line 1088 "resource/parse_date.re" { DEBUG_OUTPUT("datenocolon"); TIMELIB_INIT; @@ -16426,7 +16345,7 @@ TIMELIB_DEINIT; return TIMELIB_DATE_NOCOLON; } -#line 14248 "<stdout>" +#line 14167 "<stdout>" yy1071: YYDEBUG(1071, *YYCURSOR); yych = *++YYCURSOR; @@ -16524,7 +16443,7 @@ yy1081: YYDEBUG(1081, *YYCURSOR); -#line 1181 "resource/parse_date.re" +#line 1100 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx"); @@ -16545,7 +16464,7 @@ TIMELIB_DEINIT; return TIMELIB_XMLRPC_SOAP; } -#line 14345 "<stdout>" +#line 14264 "<stdout>" yy1082: YYDEBUG(1082, *YYCURSOR); yych = *++YYCURSOR; @@ -17148,7 +17067,7 @@ yy1172: YYDEBUG(1172, *YYCURSOR); -#line 1068 "resource/parse_date.re" +#line 987 "resource/parse_date.re" { DEBUG_OUTPUT("iso8601date | iso8601dateslash | dateslash"); TIMELIB_INIT; @@ -17159,7 +17078,7 @@ TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 14777 "<stdout>" +#line 14696 "<stdout>" yy1173: YYDEBUG(1173, *YYCURSOR); yych = *++YYCURSOR; @@ -17932,7 +17851,7 @@ yy1263: YYDEBUG(1263, *YYCURSOR); -#line 990 "resource/parse_date.re" +#line 909 "resource/parse_date.re" { DEBUG_OUTPUT("gnunocolon"); TIMELIB_INIT; @@ -17953,7 +17872,7 @@ TIMELIB_DEINIT; return TIMELIB_GNU_NOCOLON; } -#line 15387 "<stdout>" +#line 15306 "<stdout>" yy1264: YYDEBUG(1264, *YYCURSOR); yych = *++YYCURSOR; @@ -18050,7 +17969,7 @@ yy1271: YYDEBUG(1271, *YYCURSOR); -#line 1035 "resource/parse_date.re" +#line 954 "resource/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("iso8601nocolon"); @@ -18067,7 +17986,7 @@ TIMELIB_DEINIT; return TIMELIB_ISO_NOCOLON; } -#line 15485 "<stdout>" +#line 15404 "<stdout>" yy1272: YYDEBUG(1272, *YYCURSOR); yyaccept = 21; @@ -18364,7 +18283,7 @@ yy1296: YYDEBUG(1296, *YYCURSOR); -#line 927 "resource/parse_date.re" +#line 846 "resource/parse_date.re" { timelib_ull i; @@ -18387,7 +18306,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15749 "<stdout>" +#line 15668 "<stdout>" yy1297: YYDEBUG(1297, *YYCURSOR); yych = *++YYCURSOR; @@ -18458,7 +18377,7 @@ yy1305: YYDEBUG(1305, *YYCURSOR); -#line 915 "resource/parse_date.re" +#line 834 "resource/parse_date.re" { DEBUG_OUTPUT("tomorrow"); TIMELIB_INIT; @@ -18469,7 +18388,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15813 "<stdout>" +#line 15732 "<stdout>" yy1306: YYDEBUG(1306, *YYCURSOR); yych = *++YYCURSOR; @@ -18482,7 +18401,7 @@ yy1308: YYDEBUG(1308, *YYCURSOR); -#line 905 "resource/parse_date.re" +#line 824 "resource/parse_date.re" { DEBUG_OUTPUT("today"); TIMELIB_INIT; @@ -18491,7 +18410,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15829 "<stdout>" +#line 15748 "<stdout>" yy1309: YYDEBUG(1309, *YYCURSOR); yych = *++YYCURSOR; @@ -18525,7 +18444,7 @@ yy1311: YYDEBUG(1311, *YYCURSOR); -#line 896 "resource/parse_date.re" +#line 815 "resource/parse_date.re" { DEBUG_OUTPUT("now"); TIMELIB_INIT; @@ -18533,7 +18452,7 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15865 "<stdout>" +#line 15784 "<stdout>" yy1312: YYDEBUG(1312, *YYCURSOR); yych = *++YYCURSOR; @@ -18591,7 +18510,7 @@ yy1320: YYDEBUG(1320, *YYCURSOR); -#line 884 "resource/parse_date.re" +#line 803 "resource/parse_date.re" { DEBUG_OUTPUT("yesterday"); TIMELIB_INIT; @@ -18602,10 +18521,10 @@ TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 15916 "<stdout>" +#line 15835 "<stdout>" } } -#line 1432 "resource/parse_date.re" +#line 1351 "resource/parse_date.re" } @@ -18682,11 +18601,11 @@ */ } -char *timelib_timezone_id_from_abbr(const char *abbr) +char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst) { timelib_tz_lookup_table *tp; - tp = zone_search(abbr, 0, sizeof(timelib_timezone_lookup) / sizeof(*timelib_timezone_lookup) - 1); + tp = zone_search(abbr, gmtoffset, isdst); if (tp) { return (tp->full_tz_name); } else { http://cvs.php.net/diff.php/php-src/ext/date/lib/timelib.h?r1=1.10.2.2&r2=1.10.2.3&ty=u Index: php-src/ext/date/lib/timelib.h diff -u php-src/ext/date/lib/timelib.h:1.10.2.2 php-src/ext/date/lib/timelib.h:1.10.2.3 --- php-src/ext/date/lib/timelib.h:1.10.2.2 Fri Sep 2 05:33:08 2005 +++ php-src/ext/date/lib/timelib.h Sat Oct 1 11:04:07 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: timelib.h,v 1.10.2.2 2005/09/02 09:33:08 derick Exp $ */ +/* $Id: timelib.h,v 1.10.2.3 2005/10/01 15:04:07 derick Exp $ */ #ifndef __TIMELIB_H__ #define __TIMELIB_H__ @@ -49,7 +49,7 @@ /* From parse_date.re */ timelib_time *timelib_strtotime(char *s, int *errors); void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options); -char *timelib_timezone_id_from_abbr(const char *abbr); +char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst); timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void); /* From tm2unixtime.c */ http://cvs.php.net/diff.php/php-src/ext/date/lib/timelib_structs.h?r1=1.13&r2=1.13.2.1&ty=u Index: php-src/ext/date/lib/timelib_structs.h diff -u php-src/ext/date/lib/timelib_structs.h:1.13 php-src/ext/date/lib/timelib_structs.h:1.13.2.1 --- php-src/ext/date/lib/timelib_structs.h:1.13 Wed Aug 3 10:06:50 2005 +++ php-src/ext/date/lib/timelib_structs.h Sat Oct 1 11:04:07 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: timelib_structs.h,v 1.13 2005/08/03 14:06:50 sniper Exp $ */ +/* $Id: timelib_structs.h,v 1.13.2.1 2005/10/01 15:04:07 derick Exp $ */ #ifndef __TIMELIB_STRUCTS_H__ #define __TIMELIB_STRUCTS_H__ @@ -149,7 +149,7 @@ typedef struct _timelib_tz_lookup_table { char *name; int type; - int value; + int gmtoffset; char *full_tz_name; } timelib_tz_lookup_table; http://cvs.php.net/diff.php/php-src/ext/date/lib/resource/parse_date.re?r1=1.26.2.3&r2=1.26.2.4&ty=u Index: php-src/ext/date/lib/resource/parse_date.re diff -u php-src/ext/date/lib/resource/parse_date.re:1.26.2.3 php-src/ext/date/lib/resource/parse_date.re:1.26.2.4 --- php-src/ext/date/lib/resource/parse_date.re:1.26.2.3 Thu Aug 25 05:47:28 2005 +++ php-src/ext/date/lib/resource/parse_date.re Sat Oct 1 11:04:07 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: parse_date.re,v 1.26.2.3 2005/08/25 09:47:28 derick Exp $ */ +/* $Id: parse_date.re,v 1.26.2.4 2005/10/01 15:04:07 derick Exp $ */ #include "timelib.h" @@ -160,108 +160,13 @@ /* The timezone table. */ static timelib_tz_lookup_table timelib_timezone_lookup[] = { - { "a", 0, HOUR (- 1), NULL }, - { "adt", 1, HOUR ( 4), "America/Halifax" }, /* Atlantic Daylight */ - { "ahst", 0, HOUR ( 10), "America/Anchorage" }, /* Alaska-Hawaii Standard */ - { "akdt", 0, HOUR ( 10), "America/Anchorage" }, /* Alaska Daylight */ - { "akst", 0, HOUR ( 10), "America/Anchorage" }, /* Alaska Standard */ - { "ast", 0, HOUR ( 4), "America/Halifax" }, /* Atlantic Standard */ - { "at", 0, HOUR ( 2), "Atlantic/Azores" }, /* Azores */ - { "b", 0, HOUR (- 2), NULL }, - { "bst", 1, HOUR ( 0), "Europe/London" }, /* British Summer */ - { "bt", 0, -HOUR ( 3), "Asia/Baghdad" }, /* Baghdad, USSR Zone 2 */ - { "c", 0, HOUR (- 3), NULL }, - { "cadt", 1, -HOUR (9.5), "Australia/Adelaide" }, /* Central Australian Daylight */ - { "cast", 0, -HOUR (9.5), "Australia/Adelaide" }, /* Central Australian Standard */ - { "cat", 0, HOUR ( 10), "America/Anchorage" }, /* Central Alaska */ - { "cct", 0, -HOUR ( 8), "Asia/Shanghai" }, /* China Coast, USSR Zone 7 */ - { "cdt", 1, HOUR ( 6), "America/Chicago" }, /* Central Daylight */ - { "cest", 1, -HOUR ( 1), "Europe/Berlin" }, /* Central European Summer */ - { "cet", 0, -HOUR ( 1), "Europe/Berlin" }, /* Central European */ - { "cst", 0, HOUR ( 6), "America/Chicago" }, /* Central Standard */ - { "d", 0, HOUR (- 4), NULL }, - { "e", 0, HOUR (- 5), NULL }, - { "eadt", 1, -HOUR ( 10), "Australia/Sydney" }, /* Eastern Australian Daylight */ - { "east", 0, -HOUR ( 10), "Australia/Sydney" }, /* Eastern Australian Standard */ - { "edt", 1, HOUR ( 5), "America/New_York" }, /* Eastern Daylight */ - { "eest", 1, HOUR ( 2), "Europe/Helsinki" }, /* Eastern European Summer */ - { "eet", 0, -HOUR ( 2), "Europe/Bucharest" }, /* Eastern Europe, USSR Zone 1 */ - { "est", 0, HOUR ( 5), "America/New_York" }, /* Eastern Standard */ - { "f", 0, HOUR (- 6), NULL }, - { "fst", 1, -HOUR ( 1), "Europe/Paris" }, /* French Summer */ - { "fwt", 0, -HOUR ( 1), "Europe/Paris" }, /* French Winter */ - { "g", 0, HOUR (- 7), NULL }, - { "gmt", 0, HOUR ( 0), "GMT" }, /* Greenwich Mean */ - { "gst", 0, -HOUR ( 10), "Pacific/Guam" }, /* Guam Standard, USSR Zone 9 */ - { "h", 0, HOUR (- 8), NULL }, - { "hdt", 1, HOUR ( 10), "Pacific/Honolulu" }, /* Hawaii Daylight */ - { "hst", 0, HOUR ( 10), "Pacific/Honolulu" }, /* Hawaii Standard */ - { "i", 0, HOUR (- 9), NULL }, - { "idle", 0, -HOUR ( 12), "NZ" }, /* International Date Line East */ - { "idlw", 0, HOUR ( 12), NULL }, /* International Date Line West */ - { "ist", 0, -HOUR (5.5), "Asia/Calcutta" }, /* Indian Standard */ - { "it", 0, -HOUR (3.5), "Asia/Tehran" }, /* Iran */ - { "jst", 0, -HOUR ( 9), "Asia/Tokyo" }, /* Japan Standard, USSR Zone 8 */ - { "jt", 0, -HOUR (7.5), NULL }, /* Java (3pm in Cronusland!) */ - { "k", 0, HOUR (-10), NULL }, - { "l", 0, HOUR (-11), NULL }, - { "m", 0, HOUR (-12), NULL }, - { "mdt", 1, HOUR ( 7), "America/Phoenix" }, /* Mountain Daylight */ - { "mest", 1, -HOUR ( 1), "MET" }, /* Middle European Summer */ - { "mesz", 1, -HOUR ( 1), "MET" }, /* Middle European Summer */ - { "met", 0, -HOUR ( 1), "MET" }, /* Middle European */ - { "mewt", 0, -HOUR ( 1), "MET" }, /* Middle European Winter */ - { "msd", 1, HOUR ( 3), "Europe/Moscow" }, /* Moscow Summer */ - { "msk", 0, HOUR ( 3), "Europe/Moscow" }, /* Moscow */ - { "mst", 0, HOUR ( 7), "America/Phoenix" }, /* Mountain Standard */ - { "n", 0, HOUR ( 1), NULL }, - { "ndt", 1, HOUR (3.5), "America/St_Johns" }, /* Newfoundland Daylight */ - { "nft", 0, HOUR (3.5), "America/St_Johns" }, /* Newfoundland */ - { "nst", 0, HOUR (3.5), "America/St_Johns" }, /* Newfoundland Standard */ - { "nt", 0, HOUR ( 11), NULL }, /* Nome */ - { "nzdt", 1, -HOUR ( 12), "NZ" }, /* New Zealand Daylight */ - { "nzst", 0, -HOUR ( 12), "NZ" }, /* New Zealand Standard */ - { "nzt", 0, -HOUR ( 12), "NZ" }, /* New Zealand */ - { "o", 0, HOUR ( 2), NULL }, - { "p", 0, HOUR ( 3), NULL }, - { "pdt", 1, HOUR ( 8), "America/Los_Angeles" }, /* Pacific Daylight */ - { "pst", 0, HOUR ( 8), "America/Los_Angeles" }, /* Pacific Standard */ - { "q", 0, HOUR ( 4), NULL }, - { "r", 0, HOUR ( 5), NULL }, - { "s", 0, HOUR ( 6), NULL }, - { "slst", 1, -HOUR ( 1), "Europe/Oslo" }, /* Skien Local Summer Time */ - { "slt", 0, -HOUR ( 1), "Europe/Oslo" }, /* Skien Local Time */ - { "sst", 1, -HOUR ( 1), "Europe/Stockholm" }, /* Swedish Summer */ - { "swt", 0, -HOUR ( 1), "Europe/Stockholm" }, /* Swedish Winter */ - { "t", 0, HOUR ( 7), NULL }, - { "u", 0, HOUR ( 8), NULL }, - { "ut", 0, HOUR ( 0), "UTC" }, /* Universal (Coordinated) */ - { "utc", 0, HOUR ( 0), "UTC" }, - { "v", 0, HOUR ( 9), NULL }, - { "w", 0, HOUR ( 10), NULL }, - { "wadt", 1, -HOUR ( 7), "Australia/Perth" }, /* West Australian Daylight */ - { "wast", 0, -HOUR ( 7), "Australia/Perth" }, /* West Australian Standard */ - { "wat", 0, HOUR ( 1), "Africa/Dakar" }, /* West Africa */ - { "wet", 0, HOUR ( 0), "Europe/London" }, /* Western European */ - { "x", 0, HOUR ( 11), NULL }, - { "y", 0, HOUR ( 12), NULL }, - { "ydt", 1, HOUR ( 9), "America/Anchorage" }, /* Yukon Daylight */ - { "yst", 0, HOUR ( 9), "America/Anchorage" }, /* Yukon Standard */ - { "z", 0, HOUR ( 0), NULL }, - { "zp4", 0, -HOUR ( 4), NULL }, /* USSR Zone 3 */ - { "zp5", 0, -HOUR ( 5), NULL }, /* USSR Zone 4 */ - { "zp6", 0, -HOUR ( 6), NULL }, /* USSR Zone 5 */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", 0, HOUR ( 3), NULL }, /* Brazil Standard */ - { "gst", 0, HOUR ( 3), NULL }, /* Greenland Standard */ - - /* For completeness. NST is also Newfoundland Standard, and SST is - * also Swedish Summer. */ - { "nst", 0, -HOUR (6.5), NULL },/* North Sumatra */ - { "sst", 0, -HOUR (7), NULL }, /* South Sumatra, USSR Zone 6 */ -#endif +#include "timezonemap.h" + { NULL, 0, 0, NULL }, +}; + +static timelib_tz_lookup_table timelib_timezone_fallbackmap[] = { +#include "fallbackmap.h" + { NULL, 0, 0, NULL }, }; static timelib_relunit const timelib_relunit_lookup[] = { @@ -650,24 +555,37 @@ } } -static timelib_tz_lookup_table* zone_search(const char *word, int left, int right) +static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffset, int isdst) { - int mid, cmp; - - if (left > right) { - return NULL; /* not found */ + int first_found = 0; + timelib_tz_lookup_table *tp, *first_found_elem; + timelib_tz_lookup_table *fmp; + + for (tp = timelib_timezone_lookup; tp->name; tp++) { + if (strcasecmp(word, tp->name) == 0) { + if (!first_found) { + first_found = 1; + first_found_elem = tp; + if (gmtoffset == -1) { + return tp; + } + } + if (tp->gmtoffset == gmtoffset) { + return tp; + } + } } - - mid = (left + right) / 2; - - cmp = strcasecmp(word, timelib_timezone_lookup[mid].name); - if (cmp < 0) { - return zone_search(word, left, mid - 1); - } else if (cmp > 0) { - return zone_search(word, mid + 1, right); - } else { /* (cmp == 0) */ - return (timelib_tz_lookup_table*)&timelib_timezone_lookup[mid]; + if (first_found) { + return first_found_elem; + } + /* 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) { + return fmp; + } } + return NULL; } static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found) @@ -684,9 +602,10 @@ word = calloc(1, end - begin + 1); memcpy(word, begin, end - begin); - if ((tp = zone_search(word, 0, sizeof(timelib_timezone_lookup)/sizeof(*timelib_timezone_lookup)-1))) { - value = tp->value; + if ((tp = zone_search(word, -1, 0))) { + value = -tp->gmtoffset / 60; *dst = tp->type; + value += tp->type * 60; *found = 1; } else { *found = 0; @@ -1504,11 +1423,11 @@ */ } -char *timelib_timezone_id_from_abbr(const char *abbr) +char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst) { timelib_tz_lookup_table *tp; - tp = zone_search(abbr, 0, sizeof(timelib_timezone_lookup) / sizeof(*timelib_timezone_lookup) - 1); + tp = zone_search(abbr, gmtoffset, isdst); if (tp) { return (tp->full_tz_name); } else { http://cvs.php.net/diff.php/php-src/ext/date/tests/date_default_timezone_get-1.phpt?r1=1.2&r2=1.2.2.1&ty=u Index: php-src/ext/date/tests/date_default_timezone_get-1.phpt diff -u php-src/ext/date/tests/date_default_timezone_get-1.phpt:1.2 php-src/ext/date/tests/date_default_timezone_get-1.phpt:1.2.2.1 --- php-src/ext/date/tests/date_default_timezone_get-1.phpt:1.2 Wed Jul 20 06:06:10 2005 +++ php-src/ext/date/tests/date_default_timezone_get-1.phpt Sat Oct 1 11:04:07 2005 @@ -6,7 +6,11 @@ <?php putenv('TZ='); echo date_default_timezone_get(), "\n"; + echo date('e'), "\n"; ?> --EXPECTF-- -Strict Standards: date_default_timezone_get(): It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use 'UTC' for 'UTC' instead. in %sdate_default_timezone_get-1.php on line 3 -UTC +Strict Standards: date_default_timezone_get(): It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use 'Europe/London' for 'UTC/0.0/no DST' instead. in %sdate_default_timezone_get-1.php on line 3 +Europe/London + +Strict Standards: date(): It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use 'Europe/London' for 'UTC/0.0/no DST' instead. in %sdate_default_timezone_get-1.php on line 4 +Europe/London http://cvs.php.net/diff.php/php-src/ext/date/tests/date_default_timezone_set-1.phpt?r1=1.1&r2=1.1.2.1&ty=u Index: php-src/ext/date/tests/date_default_timezone_set-1.phpt diff -u php-src/ext/date/tests/date_default_timezone_set-1.phpt:1.1 php-src/ext/date/tests/date_default_timezone_set-1.phpt:1.1.2.1 --- php-src/ext/date/tests/date_default_timezone_set-1.phpt:1.1 Wed Jul 20 04:31:02 2005 +++ php-src/ext/date/tests/date_default_timezone_set-1.phpt Sat Oct 1 11:04:07 2005 @@ -5,16 +5,24 @@ --FILE-- <?php putenv("TZ="); - $date1 = strtotime("2005-07-12 08:00:00"); - date_default_timezone_set("America/Indiana/Knox"); + $date1 = strtotime("2005-01-12 08:00:00"); $date2 = strtotime("2005-07-12 08:00:00"); + date_default_timezone_set("America/Indiana/Knox"); + $date3 = strtotime("2005-01-12 08:00:00"); + $date4 = strtotime("2005-07-12 08:00:00"); echo date_default_timezone_get(), "\n"; echo date(DATE_ISO8601, $date1), "\n"; echo date(DATE_ISO8601, $date2), "\n"; + echo date(DATE_ISO8601, $date3), "\n"; + echo date(DATE_ISO8601, $date4), "\n"; ?> --EXPECTF-- -Strict Standards: strtotime(): It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use 'UTC' for 'UTC' instead. in %sdate_default_timezone_set-1.php on line 3 +Strict Standards: strtotime(): It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use 'Europe/London' for 'UTC/0.0/no DST' instead. in %sdate_default_timezone_set-1.php on line 3 + +Strict Standards: strtotime(): It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We use 'Europe/London' for 'UTC/0.0/no DST' instead. in %sdate_default_timezone_set-1.php on line 4 America/Indiana/Knox -2005-07-12T03:00:00-0500 +2005-01-12T03:00:00-0500 +2005-07-12T02:00:00-0500 +2005-01-12T08:00:00-0500 2005-07-12T08:00:00-0500 http://cvs.php.net/co.php/php-src/ext/date/lib/fallbackmap.h?r=1.1&p=1 Index: php-src/ext/date/lib/fallbackmap.h +++ php-src/ext/date/lib/fallbackmap.h http://cvs.php.net/co.php/php-src/ext/date/lib/timezonemap.h?r=1.1&p=1 Index: php-src/ext/date/lib/timezonemap.h +++ php-src/ext/date/lib/timezonemap.h
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php