summaryrefslogtreecommitdiff
path: root/ext/date/lib/parse_date.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date/lib/parse_date.c')
-rw-r--r--ext/date/lib/parse_date.c298
1 files changed, 119 insertions, 179 deletions
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index a2f339a52c..fbc76402ab 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:20:45 2014 */
+/* Generated by re2c 0.13.5 on Mon Aug 18 18:28:27 2014 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -170,8 +170,6 @@ typedef struct _timelib_relunit {
int multiplier;
} timelib_relunit;
-#define HOUR(a) (int)(a * 60)
-
/* The timezone table. */
const static timelib_tz_lookup_table timelib_timezone_lookup[] = {
#include "timezonemap.h"
@@ -535,39 +533,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
return dir * timelib_get_nr(ptr, max_length);
}
-static long timelib_parse_tz_cor(char **ptr)
-{
- char *begin = *ptr, *end;
- long tmp;
-
- while (isdigit(**ptr) || **ptr == ':') {
- ++*ptr;
- }
- end = *ptr;
- switch (end - begin) {
- case 1:
- case 2:
- return HOUR(strtol(begin, NULL, 10));
- break;
- case 3:
- case 4:
- if (begin[1] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
- return tmp;
- } else if (begin[2] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- } else {
- tmp = strtol(begin, NULL, 10);
- return HOUR(tmp / 100) + tmp % 100;
- }
- case 5:
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- }
- return 0;
-}
-
static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior)
{
char *word;
@@ -705,7 +670,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;
@@ -733,25 +698,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++) {
@@ -762,7 +708,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;
@@ -776,7 +722,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;
@@ -789,7 +735,7 @@ static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found
return value;
}
-static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper)
+long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper)
{
timelib_tzinfo *res;
long retval = 0;
@@ -820,33 +766,26 @@ static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_
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;
@@ -875,11 +814,11 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
std:
s->tok = cursor;
s->len = 0;
-#line 1001 "ext/date/lib/parse_date.re"
+#line 940 "ext/date/lib/parse_date.re"
-#line 883 "ext/date/lib/parse_date.c"
+#line 822 "ext/date/lib/parse_date.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -1019,20 +958,20 @@ yy2:
}
yy3:
YYDEBUG(3, *YYCURSOR);
-#line 1681 "ext/date/lib/parse_date.re"
+#line 1620 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("tzcorrection | tz");
TIMELIB_INIT;
TIMELIB_HAVE_TZ();
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
+ s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
TIMELIB_DEINIT;
return TIMELIB_TIMEZONE;
}
-#line 1036 "ext/date/lib/parse_date.c"
+#line 975 "ext/date/lib/parse_date.c"
yy4:
YYDEBUG(4, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1343,12 +1282,12 @@ yy11:
if (yych <= '9') goto yy1385;
yy12:
YYDEBUG(12, *YYCURSOR);
-#line 1776 "ext/date/lib/parse_date.re"
+#line 1715 "ext/date/lib/parse_date.re"
{
add_error(s, "Unexpected character");
goto std;
}
-#line 1352 "ext/date/lib/parse_date.c"
+#line 1291 "ext/date/lib/parse_date.c"
yy13:
YYDEBUG(13, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2405,11 +2344,11 @@ yy48:
if (yych <= '9') goto yy54;
yy49:
YYDEBUG(49, *YYCURSOR);
-#line 1765 "ext/date/lib/parse_date.re"
+#line 1704 "ext/date/lib/parse_date.re"
{
goto std;
}
-#line 2413 "ext/date/lib/parse_date.c"
+#line 2352 "ext/date/lib/parse_date.c"
yy50:
YYDEBUG(50, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2418,12 +2357,12 @@ yy51:
YYDEBUG(51, *YYCURSOR);
++YYCURSOR;
YYDEBUG(52, *YYCURSOR);
-#line 1770 "ext/date/lib/parse_date.re"
+#line 1709 "ext/date/lib/parse_date.re"
{
s->pos = cursor; s->line++;
goto std;
}
-#line 2427 "ext/date/lib/parse_date.c"
+#line 2366 "ext/date/lib/parse_date.c"
yy53:
YYDEBUG(53, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2810,7 +2749,7 @@ yy71:
if (yych == 's') goto yy73;
yy72:
YYDEBUG(72, *YYCURSOR);
-#line 1749 "ext/date/lib/parse_date.re"
+#line 1688 "ext/date/lib/parse_date.re"
{
timelib_ull i;
DEBUG_OUTPUT("relative");
@@ -2825,7 +2764,7 @@ yy72:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 2829 "ext/date/lib/parse_date.c"
+#line 2768 "ext/date/lib/parse_date.c"
yy73:
YYDEBUG(73, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3587,7 +3526,7 @@ yy165:
}
yy166:
YYDEBUG(166, *YYCURSOR);
-#line 1612 "ext/date/lib/parse_date.re"
+#line 1551 "ext/date/lib/parse_date.re"
{
const timelib_relunit* relunit;
DEBUG_OUTPUT("daytext");
@@ -3604,7 +3543,7 @@ yy166:
TIMELIB_DEINIT;
return TIMELIB_WEEKDAY;
}
-#line 3608 "ext/date/lib/parse_date.c"
+#line 3547 "ext/date/lib/parse_date.c"
yy167:
YYDEBUG(167, *YYCURSOR);
yych = *++YYCURSOR;
@@ -4124,7 +4063,7 @@ yy192:
}
yy193:
YYDEBUG(193, *YYCURSOR);
-#line 1671 "ext/date/lib/parse_date.re"
+#line 1610 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("monthtext");
TIMELIB_INIT;
@@ -4133,7 +4072,7 @@ yy193:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 4137 "ext/date/lib/parse_date.c"
+#line 4076 "ext/date/lib/parse_date.c"
yy194:
YYDEBUG(194, *YYCURSOR);
++YYCURSOR;
@@ -4184,7 +4123,7 @@ yy197:
}
yy198:
YYDEBUG(198, *YYCURSOR);
-#line 1417 "ext/date/lib/parse_date.re"
+#line 1356 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datetextual | datenoyear");
@@ -4197,7 +4136,7 @@ yy198:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 4201 "ext/date/lib/parse_date.c"
+#line 4140 "ext/date/lib/parse_date.c"
yy199:
YYDEBUG(199, *YYCURSOR);
yyaccept = 6;
@@ -4466,7 +4405,7 @@ yy221:
}
yy222:
YYDEBUG(222, *YYCURSOR);
-#line 1719 "ext/date/lib/parse_date.re"
+#line 1658 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz");
@@ -4487,7 +4426,7 @@ yy222:
}
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
+ s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
@@ -4495,7 +4434,7 @@ yy222:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
-#line 4499 "ext/date/lib/parse_date.c"
+#line 4438 "ext/date/lib/parse_date.c"
yy223:
YYDEBUG(223, *YYCURSOR);
yyaccept = 7;
@@ -5193,7 +5132,7 @@ yy277:
YYDEBUG(277, *YYCURSOR);
++YYCURSOR;
YYDEBUG(278, *YYCURSOR);
-#line 1695 "ext/date/lib/parse_date.re"
+#line 1634 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12");
TIMELIB_INIT;
@@ -5216,7 +5155,7 @@ yy277:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
-#line 5220 "ext/date/lib/parse_date.c"
+#line 5159 "ext/date/lib/parse_date.c"
yy279:
YYDEBUG(279, *YYCURSOR);
yych = *++YYCURSOR;
@@ -5394,7 +5333,7 @@ yy293:
++YYCURSOR;
yy294:
YYDEBUG(294, *YYCURSOR);
-#line 1389 "ext/date/lib/parse_date.re"
+#line 1328 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenoday");
@@ -5407,7 +5346,7 @@ yy294:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 5411 "ext/date/lib/parse_date.c"
+#line 5350 "ext/date/lib/parse_date.c"
yy295:
YYDEBUG(295, *YYCURSOR);
yych = *++YYCURSOR;
@@ -6627,7 +6566,7 @@ yy361:
if (yych <= '9') goto yy364;
yy363:
YYDEBUG(363, *YYCURSOR);
-#line 1533 "ext/date/lib/parse_date.re"
+#line 1472 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextshort");
@@ -6640,7 +6579,7 @@ yy363:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 6644 "ext/date/lib/parse_date.c"
+#line 6583 "ext/date/lib/parse_date.c"
yy364:
YYDEBUG(364, *YYCURSOR);
yych = *++YYCURSOR;
@@ -7278,7 +7217,7 @@ yy391:
}
yy392:
YYDEBUG(392, *YYCURSOR);
-#line 1591 "ext/date/lib/parse_date.re"
+#line 1530 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("ago");
TIMELIB_INIT;
@@ -7298,7 +7237,7 @@ yy392:
TIMELIB_DEINIT;
return TIMELIB_AGO;
}
-#line 7302 "ext/date/lib/parse_date.c"
+#line 7241 "ext/date/lib/parse_date.c"
yy393:
YYDEBUG(393, *YYCURSOR);
yyaccept = 5;
@@ -9048,7 +8987,7 @@ yy453:
++YYCURSOR;
yy454:
YYDEBUG(454, *YYCURSOR);
-#line 1294 "ext/date/lib/parse_date.re"
+#line 1233 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash");
TIMELIB_INIT;
@@ -9059,7 +8998,7 @@ yy454:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 9063 "ext/date/lib/parse_date.c"
+#line 9002 "ext/date/lib/parse_date.c"
yy455:
YYDEBUG(455, *YYCURSOR);
yyaccept = 0;
@@ -9619,7 +9558,7 @@ yy474:
}
yy475:
YYDEBUG(475, *YYCURSOR);
-#line 1431 "ext/date/lib/parse_date.re"
+#line 1370 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenoyearrev");
TIMELIB_INIT;
@@ -9630,7 +9569,7 @@ yy475:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 9634 "ext/date/lib/parse_date.c"
+#line 9573 "ext/date/lib/parse_date.c"
yy476:
YYDEBUG(476, *YYCURSOR);
yyaccept = 10;
@@ -9771,7 +9710,7 @@ yy487:
YYDEBUG(487, *YYCURSOR);
++YYCURSOR;
YYDEBUG(488, *YYCURSOR);
-#line 1149 "ext/date/lib/parse_date.re"
+#line 1088 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
TIMELIB_INIT;
@@ -9787,7 +9726,7 @@ yy487:
TIMELIB_DEINIT;
return TIMELIB_TIME12;
}
-#line 9791 "ext/date/lib/parse_date.c"
+#line 9730 "ext/date/lib/parse_date.c"
yy489:
YYDEBUG(489, *YYCURSOR);
yyaccept = 11;
@@ -9800,7 +9739,7 @@ yy489:
}
yy490:
YYDEBUG(490, *YYCURSOR);
-#line 1186 "ext/date/lib/parse_date.re"
+#line 1125 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
@@ -9817,7 +9756,7 @@ yy490:
}
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
+ s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
@@ -9825,7 +9764,7 @@ yy490:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
-#line 9829 "ext/date/lib/parse_date.c"
+#line 9768 "ext/date/lib/parse_date.c"
yy491:
YYDEBUG(491, *YYCURSOR);
yyaccept = 11;
@@ -10135,7 +10074,7 @@ yy522:
YYDEBUG(522, *YYCURSOR);
++YYCURSOR;
YYDEBUG(523, *YYCURSOR);
-#line 1166 "ext/date/lib/parse_date.re"
+#line 1105 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("mssqltime");
TIMELIB_INIT;
@@ -10154,7 +10093,7 @@ yy522:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
-#line 10158 "ext/date/lib/parse_date.c"
+#line 10097 "ext/date/lib/parse_date.c"
yy524:
YYDEBUG(524, *YYCURSOR);
yyaccept = 11;
@@ -10260,7 +10199,7 @@ yy533:
if (yych <= '9') goto yy540;
yy534:
YYDEBUG(534, *YYCURSOR);
-#line 1348 "ext/date/lib/parse_date.re"
+#line 1287 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datefull");
@@ -10274,7 +10213,7 @@ yy534:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL;
}
-#line 10278 "ext/date/lib/parse_date.c"
+#line 10217 "ext/date/lib/parse_date.c"
yy535:
YYDEBUG(535, *YYCURSOR);
yych = *++YYCURSOR;
@@ -11011,7 +10950,7 @@ yy604:
YYDEBUG(605, *YYCURSOR);
++YYCURSOR;
YYDEBUG(606, *YYCURSOR);
-#line 1363 "ext/date/lib/parse_date.re"
+#line 1302 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pointed date YYYY");
TIMELIB_INIT;
@@ -11022,7 +10961,7 @@ yy604:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
-#line 11026 "ext/date/lib/parse_date.c"
+#line 10965 "ext/date/lib/parse_date.c"
yy607:
YYDEBUG(607, *YYCURSOR);
yyaccept = 11;
@@ -11058,7 +10997,7 @@ yy610:
if (yych <= '9') goto yy604;
yy611:
YYDEBUG(611, *YYCURSOR);
-#line 1375 "ext/date/lib/parse_date.re"
+#line 1314 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pointed date YY");
@@ -11071,7 +11010,7 @@ yy611:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
-#line 11075 "ext/date/lib/parse_date.c"
+#line 11014 "ext/date/lib/parse_date.c"
yy612:
YYDEBUG(612, *YYCURSOR);
yyaccept = 11;
@@ -11712,7 +11651,7 @@ yy655:
}
yy656:
YYDEBUG(656, *YYCURSOR);
-#line 1334 "ext/date/lib/parse_date.re"
+#line 1273 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshort");
@@ -11725,7 +11664,7 @@ yy656:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 11729 "ext/date/lib/parse_date.c"
+#line 11668 "ext/date/lib/parse_date.c"
yy657:
YYDEBUG(657, *YYCURSOR);
yyaccept = 13;
@@ -11831,7 +11770,7 @@ yy665:
}
yy666:
YYDEBUG(666, *YYCURSOR);
-#line 1278 "ext/date/lib/parse_date.re"
+#line 1217 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("americanshort | american");
@@ -11846,7 +11785,7 @@ yy666:
TIMELIB_DEINIT;
return TIMELIB_AMERICAN;
}
-#line 11850 "ext/date/lib/parse_date.c"
+#line 11789 "ext/date/lib/parse_date.c"
yy667:
YYDEBUG(667, *YYCURSOR);
yyaccept = 14;
@@ -12079,7 +12018,7 @@ yy699:
if (yych <= ':') goto yy703;
yy700:
YYDEBUG(700, *YYCURSOR);
-#line 1561 "ext/date/lib/parse_date.re"
+#line 1500 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("clf");
@@ -12092,14 +12031,14 @@ yy700:
s->time->h = timelib_get_nr((char **) &ptr, 2);
s->time->i = timelib_get_nr((char **) &ptr, 2);
s->time->s = timelib_get_nr((char **) &ptr, 2);
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
+ s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 12103 "ext/date/lib/parse_date.c"
+#line 12042 "ext/date/lib/parse_date.c"
yy701:
YYDEBUG(701, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12651,7 +12590,7 @@ yy762:
}
yy763:
YYDEBUG(763, *YYCURSOR);
-#line 1306 "ext/date/lib/parse_date.re"
+#line 1245 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("iso8601date2");
@@ -12664,7 +12603,7 @@ yy763:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 12668 "ext/date/lib/parse_date.c"
+#line 12607 "ext/date/lib/parse_date.c"
yy764:
YYDEBUG(764, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12703,7 +12642,7 @@ yy770:
YYDEBUG(770, *YYCURSOR);
++YYCURSOR;
YYDEBUG(771, *YYCURSOR);
-#line 1547 "ext/date/lib/parse_date.re"
+#line 1486 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextreverse");
@@ -12716,7 +12655,7 @@ yy770:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 12720 "ext/date/lib/parse_date.c"
+#line 12659 "ext/date/lib/parse_date.c"
yy772:
YYDEBUG(772, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12854,7 +12793,7 @@ yy782:
}
yy783:
YYDEBUG(783, *YYCURSOR);
-#line 1582 "ext/date/lib/parse_date.re"
+#line 1521 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("year4");
TIMELIB_INIT;
@@ -12862,7 +12801,7 @@ yy783:
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 12866 "ext/date/lib/parse_date.c"
+#line 12805 "ext/date/lib/parse_date.c"
yy784:
YYDEBUG(784, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13013,7 +12952,7 @@ yy792:
}
yy793:
YYDEBUG(793, *YYCURSOR);
-#line 1403 "ext/date/lib/parse_date.re"
+#line 1342 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenodayrev");
@@ -13026,7 +12965,7 @@ yy793:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 13030 "ext/date/lib/parse_date.c"
+#line 12969 "ext/date/lib/parse_date.c"
yy794:
YYDEBUG(794, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13241,7 +13180,7 @@ yy813:
if (yych <= '7') goto yy816;
yy814:
YYDEBUG(814, *YYCURSOR);
-#line 1514 "ext/date/lib/parse_date.re"
+#line 1453 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweek");
@@ -13259,7 +13198,7 @@ yy814:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 13263 "ext/date/lib/parse_date.c"
+#line 13202 "ext/date/lib/parse_date.c"
yy815:
YYDEBUG(815, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13269,7 +13208,7 @@ yy816:
YYDEBUG(816, *YYCURSOR);
++YYCURSOR;
YYDEBUG(817, *YYCURSOR);
-#line 1495 "ext/date/lib/parse_date.re"
+#line 1434 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweekday");
@@ -13287,7 +13226,7 @@ yy816:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 13291 "ext/date/lib/parse_date.c"
+#line 13230 "ext/date/lib/parse_date.c"
yy818:
YYDEBUG(818, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13351,7 +13290,7 @@ yy820:
}
yy821:
YYDEBUG(821, *YYCURSOR);
-#line 1481 "ext/date/lib/parse_date.re"
+#line 1420 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgydotd");
@@ -13364,7 +13303,7 @@ yy821:
TIMELIB_DEINIT;
return TIMELIB_PG_YEARDAY;
}
-#line 13368 "ext/date/lib/parse_date.c"
+#line 13307 "ext/date/lib/parse_date.c"
yy822:
YYDEBUG(822, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13467,7 +13406,7 @@ yy841:
++YYCURSOR;
yy842:
YYDEBUG(842, *YYCURSOR);
-#line 1455 "ext/date/lib/parse_date.re"
+#line 1394 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif");
@@ -13483,7 +13422,7 @@ yy842:
if (*ptr == '.') {
s->time->f = timelib_get_frac_nr((char **) &ptr, 9);
if (*ptr) { /* timezone is optional */
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
+ s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
@@ -13492,7 +13431,7 @@ yy842:
TIMELIB_DEINIT;
return TIMELIB_XMLRPC_SOAP;
}
-#line 13496 "ext/date/lib/parse_date.c"
+#line 13435 "ext/date/lib/parse_date.c"
yy843:
YYDEBUG(843, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13754,7 +13693,7 @@ yy847:
}
yy848:
YYDEBUG(848, *YYCURSOR);
-#line 1443 "ext/date/lib/parse_date.re"
+#line 1382 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenocolon");
TIMELIB_INIT;
@@ -13765,7 +13704,7 @@ yy848:
TIMELIB_DEINIT;
return TIMELIB_DATE_NOCOLON;
}
-#line 13769 "ext/date/lib/parse_date.c"
+#line 13708 "ext/date/lib/parse_date.c"
yy849:
YYDEBUG(849, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14685,7 +14624,7 @@ yy972:
if (yych <= '9') goto yy995;
yy973:
YYDEBUG(973, *YYCURSOR);
-#line 1320 "ext/date/lib/parse_date.re"
+#line 1259 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshorter");
@@ -14698,7 +14637,7 @@ yy973:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 14702 "ext/date/lib/parse_date.c"
+#line 14641 "ext/date/lib/parse_date.c"
yy974:
YYDEBUG(974, *YYCURSOR);
yyaccept = 22;
@@ -15707,7 +15646,7 @@ yy1065:
}
yy1067:
YYDEBUG(1067, *YYCURSOR);
-#line 1212 "ext/date/lib/parse_date.re"
+#line 1151 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("gnunocolon");
TIMELIB_INIT;
@@ -15729,7 +15668,7 @@ yy1067:
TIMELIB_DEINIT;
return TIMELIB_GNU_NOCOLON;
}
-#line 15733 "ext/date/lib/parse_date.c"
+#line 15672 "ext/date/lib/parse_date.c"
yy1068:
YYDEBUG(1068, *YYCURSOR);
yych = *++YYCURSOR;
@@ -15821,7 +15760,7 @@ yy1074:
}
yy1075:
YYDEBUG(1075, *YYCURSOR);
-#line 1258 "ext/date/lib/parse_date.re"
+#line 1197 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("iso8601nocolon");
@@ -15832,7 +15771,7 @@ yy1075:
s->time->s = timelib_get_nr((char **) &ptr, 2);
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
+ s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
@@ -15840,7 +15779,7 @@ yy1075:
TIMELIB_DEINIT;
return TIMELIB_ISO_NOCOLON;
}
-#line 15844 "ext/date/lib/parse_date.c"
+#line 15783 "ext/date/lib/parse_date.c"
yy1076:
YYDEBUG(1076, *YYCURSOR);
yyaccept = 25;
@@ -16738,7 +16677,7 @@ yy1116:
}
yy1117:
YYDEBUG(1117, *YYCURSOR);
-#line 1654 "ext/date/lib/parse_date.re"
+#line 1593 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16754,7 +16693,7 @@ yy1117:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 16758 "ext/date/lib/parse_date.c"
+#line 16697 "ext/date/lib/parse_date.c"
yy1118:
YYDEBUG(1118, *YYCURSOR);
++YYCURSOR;
@@ -16805,7 +16744,7 @@ yy1125:
YYDEBUG(1125, *YYCURSOR);
++YYCURSOR;
YYDEBUG(1126, *YYCURSOR);
-#line 1127 "ext/date/lib/parse_date.re"
+#line 1066 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16826,7 +16765,7 @@ yy1125:
TIMELIB_DEINIT;
return TIMELIB_WEEK_DAY_OF_MONTH;
}
-#line 16830 "ext/date/lib/parse_date.c"
+#line 16769 "ext/date/lib/parse_date.c"
yy1127:
YYDEBUG(1127, *YYCURSOR);
yyaccept = 26;
@@ -16934,7 +16873,7 @@ yy1140:
}
yy1141:
YYDEBUG(1141, *YYCURSOR);
-#line 1630 "ext/date/lib/parse_date.re"
+#line 1569 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16957,7 +16896,7 @@ yy1141:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 16961 "ext/date/lib/parse_date.c"
+#line 16900 "ext/date/lib/parse_date.c"
yy1142:
YYDEBUG(1142, *YYCURSOR);
yych = *++YYCURSOR;
@@ -19634,7 +19573,7 @@ yy1293:
goto yy1297;
yy1294:
YYDEBUG(1294, *YYCURSOR);
-#line 1104 "ext/date/lib/parse_date.re"
+#line 1043 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("backof | frontof");
TIMELIB_INIT;
@@ -19656,7 +19595,7 @@ yy1294:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
-#line 19660 "ext/date/lib/parse_date.c"
+#line 19599 "ext/date/lib/parse_date.c"
yy1295:
YYDEBUG(1295, *YYCURSOR);
yyaccept = 28;
@@ -19917,14 +19856,14 @@ yy1315:
YYDEBUG(1315, *YYCURSOR);
++YYCURSOR;
YYDEBUG(1316, *YYCURSOR);
-#line 1087 "ext/date/lib/parse_date.re"
+#line 1026 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("firstdayof | lastdayof");
TIMELIB_INIT;
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;
@@ -19933,7 +19872,7 @@ yy1315:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
-#line 19937 "ext/date/lib/parse_date.c"
+#line 19876 "ext/date/lib/parse_date.c"
yy1317:
YYDEBUG(1317, *YYCURSOR);
yyaccept = 0;
@@ -21364,7 +21303,7 @@ yy1385:
if (yych <= '9') goto yy1385;
yy1387:
YYDEBUG(1387, *YYCURSOR);
-#line 1061 "ext/date/lib/parse_date.re"
+#line 1000 "ext/date/lib/parse_date.re"
{
timelib_ull i;
@@ -21389,7 +21328,7 @@ yy1387:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21393 "ext/date/lib/parse_date.c"
+#line 21332 "ext/date/lib/parse_date.c"
yy1388:
YYDEBUG(1388, *YYCURSOR);
yych = *++YYCURSOR;
@@ -21825,7 +21764,7 @@ yy1416:
++YYCURSOR;
yy1417:
YYDEBUG(1417, *YYCURSOR);
-#line 1049 "ext/date/lib/parse_date.re"
+#line 988 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("tomorrow");
TIMELIB_INIT;
@@ -21836,7 +21775,7 @@ yy1417:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21840 "ext/date/lib/parse_date.c"
+#line 21779 "ext/date/lib/parse_date.c"
yy1418:
YYDEBUG(1418, *YYCURSOR);
yych = *++YYCURSOR;
@@ -21871,7 +21810,7 @@ yy1419:
}
yy1420:
YYDEBUG(1420, *YYCURSOR);
-#line 1039 "ext/date/lib/parse_date.re"
+#line 978 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("midnight | today");
TIMELIB_INIT;
@@ -21880,7 +21819,7 @@ yy1420:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21884 "ext/date/lib/parse_date.c"
+#line 21823 "ext/date/lib/parse_date.c"
yy1421:
YYDEBUG(1421, *YYCURSOR);
yych = *++YYCURSOR;
@@ -23892,7 +23831,7 @@ yy1499:
}
yy1500:
YYDEBUG(1500, *YYCURSOR);
-#line 1018 "ext/date/lib/parse_date.re"
+#line 957 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("now");
TIMELIB_INIT;
@@ -23900,7 +23839,7 @@ yy1500:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 23904 "ext/date/lib/parse_date.c"
+#line 23843 "ext/date/lib/parse_date.c"
yy1501:
YYDEBUG(1501, *YYCURSOR);
yych = *++YYCURSOR;
@@ -24039,7 +23978,7 @@ yy1507:
}
yy1508:
YYDEBUG(1508, *YYCURSOR);
-#line 1027 "ext/date/lib/parse_date.re"
+#line 966 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("noon");
TIMELIB_INIT;
@@ -24050,7 +23989,7 @@ yy1508:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 24054 "ext/date/lib/parse_date.c"
+#line 23993 "ext/date/lib/parse_date.c"
yy1509:
YYDEBUG(1509, *YYCURSOR);
yyaccept = 0;
@@ -24583,7 +24522,7 @@ yy1530:
++YYCURSOR;
yy1531:
YYDEBUG(1531, *YYCURSOR);
-#line 1006 "ext/date/lib/parse_date.re"
+#line 945 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("yesterday");
TIMELIB_INIT;
@@ -24594,7 +24533,7 @@ yy1531:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 24598 "ext/date/lib/parse_date.c"
+#line 24537 "ext/date/lib/parse_date.c"
yy1532:
YYDEBUG(1532, *YYCURSOR);
yyaccept = 0;
@@ -24767,7 +24706,7 @@ yy1537:
goto yy1531;
}
}
-#line 1780 "ext/date/lib/parse_date.re"
+#line 1719 "ext/date/lib/parse_date.re"
}
@@ -24826,6 +24765,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
in.tzdb = tzdb;
in.time->is_localtime = 0;
in.time->zone_type = 0;
+ in.time->relative.days = TIMELIB_UNSET;
do {
t = scan(&in, tz_get_wrapper);
@@ -25082,7 +25022,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
case 'O': /* timezone */
{
int tz_not_found;
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
+ s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_pbf_error(s, "The timezone could not be found in the database", string, begin);
}
@@ -25257,7 +25197,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 {