diff options
Diffstat (limited to 'ext/date/lib/parse_date.c')
-rw-r--r-- | ext/date/lib/parse_date.c | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 6849fa938..d16878a3c 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Thu Jul 31 14:33:37 2014 */ +/* Generated by re2c 0.13.5 on Mon Aug 18 18:28:27 2014 */ /* +----------------------------------------------------------------------+ | PHP Version 5 | @@ -669,7 +669,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, S } } -const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffset, int isdst) +const static timelib_tz_lookup_table* abbr_search(const char *word, long gmtoffset, int isdst) { int first_found = 0; const timelib_tz_lookup_table *tp, *first_found_elem = NULL; @@ -697,25 +697,6 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs return first_found_elem; } - for (tp = timelib_timezone_lookup; tp->name; tp++) { - if (tp->full_tz_name && strcasecmp(word, tp->full_tz_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; - } - - /* Still didn't find anything, let's find the zone solely based on * offset/isdst then */ for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) { @@ -726,7 +707,7 @@ const static timelib_tz_lookup_table* zone_search(const char *word, long gmtoffs return NULL; } -static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found) +static long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, int *found) { char *word; char *begin = *ptr, *end; @@ -740,7 +721,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found word = calloc(1, end - begin + 1); memcpy(word, begin, end - begin); - if ((tp = zone_search(word, -1, 0))) { + if ((tp = abbr_search(word, -1, 0))) { value = -tp->gmtoffset / 60; *dst = tp->type; value += tp->type * 60; @@ -784,33 +765,26 @@ long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found retval = timelib_parse_tz_cor(ptr); } else { int found = 0; - long offset; + long offset = 0; char *tz_abbr; t->is_localtime = 1; - offset = timelib_lookup_zone(ptr, dst, &tz_abbr, &found); + /* First, we lookup by abbreviation only */ + offset = timelib_lookup_abbr(ptr, dst, &tz_abbr, &found); if (found) { t->zone_type = TIMELIB_ZONETYPE_ABBR; + timelib_time_tz_abbr_update(t, tz_abbr); } -#if 0 - /* If we found a TimeZone identifier, use it */ - if (tz_name) { - t->tz_info = timelib_parse_tzfile(tz_name); - t->zone_type = TIMELIB_ZONETYPE_ID; - } -#endif - /* If we have a TimeZone identifier to start with, use it */ - if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) { + + /* Otherwise, we look if we have a TimeZone identifier */ + if (!found || strcmp("UTC", tz_abbr) == 0) { if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) { t->tz_info = res; t->zone_type = TIMELIB_ZONETYPE_ID; found++; } } - if (found && t->zone_type != TIMELIB_ZONETYPE_ID) { - timelib_time_tz_abbr_update(t, tz_abbr); - } free(tz_abbr); *tz_not_found = (found == 0); retval = offset; @@ -19805,7 +19779,7 @@ yy1315: TIMELIB_HAVE_RELATIVE(); /* skip "last day of" or "first day of" */ - if (*ptr == 'l') { + if (*ptr == 'l' || *ptr == 'L') { s->time->relative.first_last_day_of = 2; } else { s->time->relative.first_last_day_of = 1; @@ -25125,7 +25099,7 @@ char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst) { const timelib_tz_lookup_table *tp; - tp = zone_search(abbr, gmtoffset, isdst); + tp = abbr_search(abbr, gmtoffset, isdst); if (tp) { return (tp->full_tz_name); } else { |