diff --git a/date.c b/date.c
index e1a4d49..b9eecfb 100644
--- a/date.c
+++ b/date.c
@@ -363,7 +363,8 @@ 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 is_date(int year, int month, int day, struct tm *now_tm, time_t now,
+ struct tm *tm, int allow_future)
{
if (month > 0 && month < 13 && day > 0 && day < 32) {
struct tm check = *tm;@@ -388,14 +389,16 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
if (!now_tm)
return 1;
- specified = tm_to_time_t(r);
+ if (!allow_future) {
+ specified = tm_to_time_t(r);
- /* Be it commit time or author time, it does not make
- * sense to specify timestamp way into the future. Make
- * sure it is not later than ten days from now...
- */
- if ((specified != -1) && (now + 10*24*3600 < specified))
- return 0;
+ /* Be it commit time or author time, it does not make
+ * sense to specify timestamp way into the future. Make
+ * sure it is not later than ten days from now...
+ */
+ if ((specified != -1) && (now + 10*24*3600 < specified))
+ return 0;
+ }
tm->tm_mon = r->tm_mon;
tm->tm_mday = r->tm_mday;
if (year != -1)@@ -441,10 +444,10 @@ static int match_multi_number(unsigned long num, char c, const char *date,
if (num > 70) {
/* yyyy-mm-dd? */
- if (is_date(num, num2, num3, refuse_future, now, tm))
+ if (is_date(num, num2, num3, refuse_future, now, tm, 1))
break;
/* yyyy-dd-mm? */
- if (is_date(num, num3, num2, refuse_future, now, tm))
+ if (is_date(num, num3, num2, refuse_future, now, tm, 1))
break;
}
/* Our eastern European friends say dd.mm.yy[yy]@@ -452,14 +455,14 @@ static int match_multi_number(unsigned long 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))
+ is_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 (is_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))
+ is_date(num3, num, num2, refuse_future, now, tm, 0))
break;
return 0;
}
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index e53cf6d..fac0986 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -82,4 +82,7 @@ check_approxidate 'Jun 6, 5AM' '2009-06-06 05:00:00'
check_approxidate '5AM Jun 6' '2009-06-06 05:00:00'
check_approxidate '6AM, June 7, 2009' '2009-06-07 06:00:00'
+check_approxidate '2008-12-01' '2008-12-01 19:20:00'
+check_approxidate '2009-12-01' '2009-12-01 19:20:00'
+
test_done
--
2.1.2.596.g7379948