All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix '--relative-date'
@ 2009-10-03  4:20 Johan Sageryd
  2009-10-03 10:06 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Sageryd @ 2009-10-03  4:20 UTC (permalink / raw)
  To: git; +Cc: Johan Sageryd

This fixes '--relative-date' so that it does not give '0 year, 12 months', for the interval 360 <= diff < 365.

Signed-off-by: Johan Sageryd <j416@1616.se>
---
 date.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/date.c b/date.c
index e9ee4aa..5d05ef6 100644
--- a/date.c
+++ b/date.c
@@ -123,7 +123,7 @@ const char *show_date_relative(unsigned long time, int tz,
 		return timebuf;
 	}
 	/* Say months for the past 12 months or so */
-	if (diff < 360) {
+	if (diff < 365) {
 		snprintf(timebuf, timebuf_size, "%lu months ago", (diff + 15) / 30);
 		return timebuf;
 	}
-- 
1.6.4.4

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

* Re: [PATCH] Fix '--relative-date'
  2009-10-03  4:20 [PATCH] Fix '--relative-date' Johan Sageryd
@ 2009-10-03 10:06 ` Jeff King
  2009-10-03 11:18   ` Johan Sageryd
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2009-10-03 10:06 UTC (permalink / raw)
  To: Johan Sageryd; +Cc: git

On Sat, Oct 03, 2009 at 01:20:18PM +0900, Johan Sageryd wrote:

> This fixes '--relative-date' so that it does not give '0 year, 12
> months', for the interval 360 <= diff < 365.

Thanks. I think this was a regression introduced recently when we fixed
the rounding on how years are printed (it used to just say "1 year"
because we were close, but now we always round down, so our boundary for
"1 year" must match exactly).

I've picked up your patch in my tree with the following test squashed
in:

diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index a4d8fa8..75b02af 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -24,6 +24,7 @@ check_show 13000000 '5 months ago'
 check_show 37500000 '1 year, 2 months ago'
 check_show 55188000 '1 year, 9 months ago'
 check_show 630000000 '20 years ago'
+check_show 31449600 '12 months ago'
 
 check_parse() {
 	echo "$1 -> $2" >expect

-Peff

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

* Re: [PATCH] Fix '--relative-date'
  2009-10-03 10:06 ` Jeff King
@ 2009-10-03 11:18   ` Johan Sageryd
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Sageryd @ 2009-10-03 11:18 UTC (permalink / raw)
  To: Jeff King; +Cc: git

> I've picked up your patch in my tree with the following test squashed
> in:
> 
> diff --git a/t/t0006-date.sh b/t/t0006-date.sh
> index a4d8fa8..75b02af 100755
> --- a/t/t0006-date.sh
> +++ b/t/t0006-date.sh
> @@ -24,6 +24,7 @@ check_show 13000000 '5 months ago'
>  check_show 37500000 '1 year, 2 months ago'
>  check_show 55188000 '1 year, 9 months ago'
>  check_show 630000000 '20 years ago'
> +check_show 31449600 '12 months ago'
>  
>  check_parse() {
>  	echo "$1 -> $2" >expect

Thank you!

/Johan

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

end of thread, other threads:[~2009-10-03 11:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-03  4:20 [PATCH] Fix '--relative-date' Johan Sageryd
2009-10-03 10:06 ` Jeff King
2009-10-03 11:18   ` Johan Sageryd

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.