summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
Diffstat (limited to 'date.c')
-rw-r--r--date.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/date.c b/date.c
index b0d9a8421d..b67c5abe24 100644
--- a/date.c
+++ b/date.c
@@ -497,7 +497,7 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
return skip_alpha(date);
}
-static int is_date(int year, int month, int day, struct tm *now_tm, time_t now, struct tm *tm)
+static int set_date(int year, int month, int day, struct tm *now_tm, time_t now, struct tm *tm)
{
if (month > 0 && month < 13 && day > 0 && day < 32) {
struct tm check = *tm;
@@ -518,9 +518,9 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
else if (year < 38)
r->tm_year = year + 100;
else
- return 0;
+ return -1;
if (!now_tm)
- return 1;
+ return 0;
specified = tm_to_time_t(r);
@@ -529,14 +529,14 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
* sure it is not later than ten days from now...
*/
if ((specified != -1) && (now + 10*24*3600 < specified))
- return 0;
+ return -1;
tm->tm_mon = r->tm_mon;
tm->tm_mday = r->tm_mday;
if (year != -1)
tm->tm_year = r->tm_year;
- return 1;
+ return 0;
}
- return 0;
+ return -1;
}
static int match_multi_number(timestamp_t num, char c, const char *date,
@@ -575,10 +575,10 @@ static int match_multi_number(timestamp_t num, char c, const char *date,
if (num > 70) {
/* yyyy-mm-dd? */
- if (is_date(num, num2, num3, NULL, now, tm))
+ if (set_date(num, num2, num3, NULL, now, tm) == 0)
break;
/* yyyy-dd-mm? */
- if (is_date(num, num3, num2, NULL, now, tm))
+ if (set_date(num, num3, num2, NULL, now, tm) == 0)
break;
}
/* Our eastern European friends say dd.mm.yy[yy]
@@ -586,14 +586,14 @@ static int match_multi_number(timestamp_t num, char c, const char *date,
* mm/dd/yy[yy] form only when separator is not '.'
*/
if (c != '.' &&
- is_date(num3, num, num2, refuse_future, now, tm))
+ set_date(num3, num, num2, refuse_future, now, tm) == 0)
break;
/* European dd.mm.yy[yy] or funny US dd/mm/yy[yy] */
- if (is_date(num3, num2, num, refuse_future, now, tm))
+ if (set_date(num3, num2, num, refuse_future, now, tm) == 0)
break;
/* Funny European mm.dd.yy */
if (c == '.' &&
- is_date(num3, num, num2, refuse_future, now, tm))
+ set_date(num3, num, num2, refuse_future, now, tm) == 0)
break;
return 0;
}