path: root/date.c
diff options
authorLinus Torvalds <>2006-01-05 03:33:55 (GMT)
committerJunio C Hamano <>2006-01-06 01:22:43 (GMT)
commitb73cebf437252660cea670c27dcdedc422e1bff9 (patch)
treec9a822d4bdd0feb3f6c307689fe16ac56c32d660 /date.c
parent0a15217184f20649c0ab19b24363e35112a91beb (diff)
Fix nasty approxidate bug
Stupid me. If approxidate ends up with a month that is ahead of the current month, it decrements the year to last year. Which is correct, and means that "last december" does the right thing. HOWEVER. It should only do so if the year is the same as the current year. Without this fix, "5 days ago" ends up being in 2004, because it first decrements five days, getting us to December 2005 (correct), but then it also ends up decrementing the year once more to turn that December into "last year" (incorrect, since it already _was_ last year). Duh. Pass me a donut. Signed-off-by: Linus Torvalds <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'date.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/date.c b/date.c
index 3ede027..416ea57 100644
--- a/date.c
+++ b/date.c
@@ -640,7 +640,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)
return mktime(&tm);