From: Johan Sageryd Date: Sat, 3 Oct 2009 04:20:18 +0000 (+0900) Subject: Fix '--relative-date' X-Git-Tag: v1.6.5-rc3~7 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=dbc1b1f71052c084a84b5c395e1cb4b5ae526fcb;p=git.git Fix '--relative-date' This fixes '--relative-date' so that it does not give '0 year, 12 months', for the interval 360 <= diff < 365. Signed-off-by: Johan Sageryd Signed-off-by: Jeff King --- diff --git a/date.c b/date.c index e9ee4aa74..5d05ef61c 100644 --- a/date.c +++ b/date.c @@ -123,7 +123,7 @@ const char *show_date_relative(unsigned long time, int tz, return timebuf; } /* Say months for the past 12 months or so */ - if (diff < 360) { + if (diff < 365) { snprintf(timebuf, timebuf_size, "%lu months ago", (diff + 15) / 30); return timebuf; } diff --git a/t/t0006-date.sh b/t/t0006-date.sh index a4d8fa8fa..75b02af86 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -24,6 +24,7 @@ check_show 13000000 '5 months ago' check_show 37500000 '1 year, 2 months ago' check_show 55188000 '1 year, 9 months ago' check_show 630000000 '20 years ago' +check_show 31449600 '12 months ago' check_parse() { echo "$1 -> $2" >expect