Skip to content

Commit dbc1b1f

Browse files
Johan Sagerydpeff
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent b4ae5e2 commit dbc1b1f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const char *show_date_relative(unsigned long time, int tz,
123123
return timebuf;
124124
}
125125
/* Say months for the past 12 months or so */
126-
if (diff < 360) {
126+
if (diff < 365) {
127127
snprintf(timebuf, timebuf_size, "%lu months ago", (diff + 15) / 30);
128128
return timebuf;
129129
}

t/t0006-date.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ check_show 13000000 '5 months ago'
2424
check_show 37500000 '1 year, 2 months ago'
2525
check_show 55188000 '1 year, 9 months ago'
2626
check_show 630000000 '20 years ago'
27+
check_show 31449600 '12 months ago'
2728

2829
check_parse() {
2930
echo "$1 -> $2" >expect

0 commit comments

Comments
 (0)