Fine-tune relative-date output.
PATCH 2/2 Fine-tune relative-date output.
I've always found relative-date less useful than it could be, as it switched to coarser unit a bit too quickly, so this attempts to fine tune it to my liking.
For example, earlier we said "3 weeks ago" if it is between 18 days and 24 days; now we do not say "weeks" if it is less than a month old.
Earlier Updated
X minutes ago < 90 minutes < 3 hours X hours ago < 36 hours < 3 days X days ago < 2 weeks < 1 month X weeks ago < 10 weeks < 10 weeks X months ago < 1 year < 2 1/2 years
Signed-off-by Junio C Hamano <[email protected]>
---
* I will not strongly insist doing this, but the current setting is so annoying that I seldom use --relative-date, except when I look at reflog entries that are no older than a day.
We probably could have --relative-date=90,36,14,70,360 (or .git/config equivalent) to further fine tune this, but I personally did not feel it is worth it.
date.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
date.c +5 -5
@@ -99,19 +99,19 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode) }/* Turn it into minutes */ diff = (diff +30 ) /60 ; -if (diff <90 ) { +if (diff <180 ) {snprintf (timebuf,sizeof (timebuf),"%lu minutes ago" , diff);return timebuf; }/* Turn it into hours */ diff = (diff +30 ) /60 ; -if (diff <36 ) { +if (diff <72 ) {snprintf (timebuf,sizeof (timebuf),"%lu hours ago" , diff);return timebuf; }/* We deal with number of days from here on */ diff = (diff +12 ) /24 ; -if (diff <14 ) { +if (diff <35 ) {snprintf (timebuf,sizeof (timebuf),"%lu days ago" , diff);return timebuf; }
@@ -120,8 +120,8 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)snprintf (timebuf,sizeof (timebuf),"%lu weeks ago" , (diff +3 ) /7 );return timebuf; } -/* Say months for the past 12 months or so */ -if (diff <360 ) { +/* Say months for the past 30 months or so */ +if (diff <900 ) {snprintf (timebuf,sizeof (timebuf),"%lu months ago" , (diff +15 ) /30 );return timebuf; }
Signature · 1 line
1.5.2.rc0.719.gb3626