Skip to content

Commit

Permalink
Fix '--relative-date'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johan Sageryd authored and Jeff King committed Oct 3, 2009
1 parent b4ae5e2 commit dbc1b1f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion date.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions t/t0006-date.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dbc1b1f

Please sign in to comment.