X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=date.c;h=1c1917b4e8768b0046729e19505d6f1b0845a0d8;hb=cebff98dbe3fd6177337ae4d440b81ffed797608;hp=3e11500eda5e75a7ec354441fe4a24fd5ebf8bbc;hpb=52b6536c624b4998b3730b55b9bc3d7c4e1071a4;p=git.git diff --git a/date.c b/date.c index 3e11500e..1c1917b4 100644 --- a/date.c +++ b/date.c @@ -123,8 +123,6 @@ static const struct { { "IDLE", +12, 0, }, /* International Date Line East */ }; -#define NR_TZ (sizeof(timezone_names) / sizeof(timezone_names[0])) - static int match_string(const char *date, const char *str) { int i = 0; @@ -173,7 +171,7 @@ static int match_alpha(const char *date, struct tm *tm, int *offset) } } - for (i = 0; i < NR_TZ; i++) { + for (i = 0; i < ARRAY_SIZE(timezone_names); i++) { int match = match_string(date, timezone_names[i].name); if (match >= 3) { int off = timezone_names[i].offset; @@ -326,7 +324,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt /* * NOTE! We will give precedence to day-of-month over month or - * year numebers in the 1-12 range. So 05 is always "mday 5", + * year numbers in the 1-12 range. So 05 is always "mday 5", * unless we already have a mday.. * * IOW, 01 Apr 05 parses as "April 1st, 2005". @@ -640,7 +638,7 @@ unsigned long approxidate(const char *date) } if (number > 0 && number < 32) tm.tm_mday = number; - if (tm.tm_mon > now.tm_mon) + if (tm.tm_mon > now.tm_mon && tm.tm_year == now.tm_year) tm.tm_year--; return mktime(&tm); }