提交 b73cebf4 编写于 作者: L Linus Torvalds 提交者: Junio C Hamano

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: NLinus Torvalds <torvalds@osdl.org>
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 0a152171
......@@ -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)
tm.tm_year--;
return mktime(&tm);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册