Re: [PATCH 2/2] --date=relative falls back to "short" format for commits older than a year
- From
Jeff King <peff@peff.net>
- Date
- Feb 22, 2009, 23:06 UTC
- Message-ID
- <20090222230620.GB19011@coredump.intra.peff.net>
- In-Reply-To
- <1235165034-20299-1-git-send-email-eletuchy@gmail.com>
On Fri, Feb 20, 2009 at 01:23:54PM -0800, eletuchy@gmail.com wrote:
Show 6 quoted lines
> From: Eugene Letuchy <eugene@facebook.com> > > In the context of sizing the git blame time column, it doesn't make a > lot of sense to see "12 months ago" next to an exact timestamp + > timezone for something 13 months ago. This commit makes commits older > than 12 months display the date only, not the time.
I think this is an improvement, though I was thinking of taking it a step further:
diff --git a/date.c b/date.c index d75dff4..6dbb8e8 100644 --- a/date.c +++ b/date.c @@ -128,12 +128,14 @@ 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 24 months or so */ + if (diff < 720) { snprintf(timebuf, sizeof(timebuf), "%lu months ago", (diff + 15) / 30); return timebuf; } - /* Else fall back on absolute format.. */ + /* Otherwise, years. Centuries is probably overkill. */ + snprintf(timebuf, sizeof(timebuf), "%lu years ago", (diff + 183) / 365); + return timebuf; } if (mode == DATE_LOCAL) but maybe other people actually like seeing the absolute time. I've always found it jarring when reading relative times (but part of that _was_ because it was so long and exact). -Peff