All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Round-down years in "years+months" relative date view
@ 2009-08-27 23:39 David Reiss
  2009-08-28  6:05 ` Jeff King
  0 siblings, 1 reply; 47+ messages in thread
From: David Reiss @ 2009-08-27 23:39 UTC (permalink / raw)
  To: git

Previously, a commit from 1 year and 7 months ago would display as
"2 years, 7 months ago".

Signed-off-by: David Reiss <dreiss@facebook.com>
---

Here's my test script.  Let me know if you'd rather have it as part
of the test suite.


#!/bin/sh
set -e
REPO="git-relative-dates-test"
rm -rf "$REPO"
mkdir "$REPO"
cd "$REPO"
git init
NOW=`date +%s`
env GIT_AUTHOR_DATE=`expr $NOW - \( 365 + 220 \) \* 24 \* 60 \* 60` git commit --allow-empty -m old-commit
git log --date=relative


 date.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/date.c b/date.c
index 1de1845..e848d96 100644
--- a/date.c
+++ b/date.c
@@ -137,7 +137,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
 		}
 		/* Give years and months for 5 years or so */
 		if (diff < 1825) {
-			unsigned long years = (diff + 183) / 365;
+			unsigned long years = diff / 365;
 			unsigned long months = (diff % 365 + 15) / 30;
 			int n;
 			n = snprintf(timebuf, sizeof(timebuf), "%lu year%s",
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2009-09-01  3:04 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-27 23:39 [PATCH] Round-down years in "years+months" relative date view David Reiss
2009-08-28  6:05 ` Jeff King
2009-08-28  7:58   ` Alex Riesen
2009-08-28 15:02     ` Jeff King
2009-08-28 17:00       ` Alex Riesen
2009-08-28 17:15         ` Jeff King
2009-08-28 18:21           ` Alex Riesen
2009-08-28 22:01           ` A Large Angry SCM
2009-08-28 17:28       ` Nicolas Pitre
2009-08-28 18:01         ` Jeff King
2009-08-28 18:27           ` Alex Riesen
2009-08-28 18:39             ` Jeff King
2009-08-28 18:42               ` Alex Riesen
2009-08-28 18:49                 ` Alex Riesen
2009-08-28 19:00                 ` Nicolas Pitre
2009-08-28 19:08                   ` Alex Riesen
2009-08-28 19:27                     ` Nicolas Pitre
2009-08-28 19:49                       ` Alex Riesen
2009-08-28 20:01                         ` Nicolas Pitre
2009-08-28 19:03         ` Alex Riesen
2009-08-28 19:15           ` Jeff King
2009-08-28 19:20             ` Alex Riesen
2009-08-28 19:33               ` Alex Riesen
2009-08-28 20:52                 ` [PATCH] Allow testing of _relative family of time formatting and parsing functions Alex Riesen
2009-08-28 20:54                   ` Alex Riesen
2009-08-29 21:46                   ` Junio C Hamano
2009-08-30  7:25                     ` Alex Riesen
2009-08-30  7:51                       ` Jeff King
2009-08-30  8:10                         ` Alex Riesen
2009-08-30  9:13                       ` [PATCH 1/2] Add date formatting and parsing functions relative to a given time Alex Riesen
2009-08-30  9:15                         ` [PATCH 2/2] Allow testing of _relative family of time formatting and parsing functions Alex Riesen
2009-08-30  9:15                         ` [PATCH 1/2] Add date formatting and parsing functions relative to a given time Jeff King
2009-08-30  9:36                           ` Jeff King
2009-08-30  9:56                             ` Alex Riesen
2009-08-30 10:08                               ` Jeff King
2009-08-30 11:17                                 ` Alex Riesen
2009-08-30 21:43                             ` [PATCH 1/3] " Jeff King
2009-08-30 21:51                               ` Jeff King
2009-08-31  2:22                                 ` Jeff King
2009-08-31  2:26                                   ` [PATCH v2 1/4] " Jeff King
2009-08-31  6:08                                     ` Alex Riesen
2009-08-31  2:26                                   ` [PATCH v2 2/4] refactor test-date interface Jeff King
2009-08-31  2:30                                   ` [PATCH v2 3/4] tests: add date printing and parsing tests Jeff King
2009-09-01  3:03                                     ` Jeff King
2009-08-31  2:31                                   ` [PATCH v2 4/4] fix approxidate parsing of relative months and years Jeff King
2009-08-30 21:46                             ` [PATCH 2/3] refactor test-date interface Jeff King
2009-08-30 21:47                             ` [PATCH 3/3] tests: add date printing and parsing tests Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.