git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <junkio@cox.net>
Date
Apr 26, 2007, 05:23 UTC
Message-ID
<11775649803059-git-send-email-junkio@cox.net>

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@cox.net>
---
 * 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
Message 1 of 1 in “Fine-tune relative-date output.”
  1. 2/2 Fine-tune relative-date output.Junio C Hamano, Apr 26, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.