X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=date.c;h=316841e8ad3705559fddb0ca4aff969fdf91b011;hb=71e55854fd6e5c9ce786bcd20efef43bd56f9df0;hp=a9b59a289e7b22f34958ccc7b80b02a01cf793c6;hpb=db81e67a7d559544f8464cdfd011208e60b76344;p=git.git diff --git a/date.c b/date.c index a9b59a289..316841e8a 100644 --- a/date.c +++ b/date.c @@ -403,7 +403,7 @@ static int match_multi_number(unsigned long num, char c, const char *date, char } /* - * We've seen a digit. Time? Year? Date? + * We've seen a digit. Time? Year? Date? */ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt) { @@ -414,9 +414,11 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt num = strtoul(date, &end, 10); /* - * Seconds since 1970? We trigger on that for anything after Jan 1, 2000 + * Seconds since 1970? We trigger on that for any numbers with + * more than 8 digits. This is because we don't want to rule out + * numbers like 20070606 as a YYYYMMDD date. */ - if (num > 946684800) { + if (num >= 100000000) { time_t time = num; if (gmtime_r(&time, tm)) { *tm_gmt = 1; @@ -493,7 +495,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt } else if (num > 0 && num < 13) { tm->tm_mon = num-1; } - + return n; } @@ -567,13 +569,13 @@ int parse_date(const char *date, char *result, int maxlen) if (!match) { /* BAD CRAP */ match = 1; - } + } date += match; } /* mktime uses local timezone */ - then = my_mktime(&tm); + then = my_mktime(&tm); if (offset == -1) offset = (then - mktime(&tm)) / 60; @@ -689,7 +691,7 @@ static const struct typelen { { "days", 24*60*60 }, { "weeks", 7*24*60*60 }, { NULL } -}; +}; static const char *approxidate_alpha(const char *date, struct tm *tm, int *num) {