Skip to content

Commit

Permalink
[GH #50] Make relative dates show number of years ago for old commits
Browse files Browse the repository at this point in the history
The previous behavior was to fall back and show the timestamp.
  • Loading branch information
jonas committed May 10, 2012
1 parent 67993dd commit 5a938da
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tig.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ mkdate(const struct time *time, enum date date)
{ "hour", 60 * 60, 60 * 60 * 24 * 2 },
{ "day", 60 * 60 * 24, 60 * 60 * 24 * 7 * 2 },
{ "week", 60 * 60 * 24 * 7, 60 * 60 * 24 * 7 * 5 },
{ "month", 60 * 60 * 24 * 30, 60 * 60 * 24 * 30 * 12 },
{ "month", 60 * 60 * 24 * 30, 60 * 60 * 24 * 365 },
{ "year", 60 * 60 * 24 * 365, 0 },
};
struct tm tm;

Expand All @@ -95,7 +96,7 @@ mkdate(const struct time *time, enum date date)
gettimeofday(&now, NULL);
seconds = now.tv_sec < date ? date - now.tv_sec : now.tv_sec - date;
for (i = 0; i < ARRAY_SIZE(reldate); i++) {
if (seconds >= reldate[i].value)
if (seconds >= reldate[i].value && reldate[i].value)
continue;

seconds /= reldate[i].namelen;
Expand Down

0 comments on commit 5a938da

Please sign in to comment.