[PATCH 2/2] Fine-tune relative-date output.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <junkio@xxxxxxx>
---

 * 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(-)

diff --git a/date.c b/date.c
index a9b59a2..d2ea995 100644
--- a/date.c
+++ b/date.c
@@ -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;
 		}
-- 
1.5.2.rc0.719.gb3626

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]