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 <j416@1616.se> Signed-off-by: Jeff King <peff@peff.net>
Johan Sageryd committed
Oct 3, 2009 at 13:20 UTC
dbc1b1f71052c084a84b5c395e1cb4b5ae526fcb
2 files changed
+2
-1
date.c
+1
-1
@@ -123,7 +123,7 @@ const char *show_date_relative(unsigned long time, int tz,
123
return timebuf;
124
}
125
/* Say months for the past 12 months or so */
126
- if (diff < 360) {
126
+ if (diff < 365) {
127
snprintf(timebuf, timebuf_size, "%lu months ago", (diff + 15) / 30);
128
return timebuf;
129
}
t/t0006-date.sh
+1
@@ -24,6 +24,7 @@ check_show 13000000 '5 months ago'
24
check_show 37500000 '1 year, 2 months ago'
25
check_show 55188000 '1 year, 9 months ago'
26
check_show 630000000 '20 years ago'
27
+check_show 31449600 '12 months ago'
28
29
check_parse() {
30
echo "$1 -> $2" >expect