git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Øyvind A. Holm" <sunny@sunbase.org>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	sunny@sunbase.org
Subject: [PATCH REMINDER] date.c: print "1 second ago", not "1 seconds ago"
Date: Sat, 8 May 2010 11:27:30 +0200	[thread overview]
Message-ID: <20100508092730.GB26678@triton> (raw)

Hi,
resending a trivial patch for correcting the output of "1 seconds" to 
"1 second" when using --date=relative. The original patch was sent 
2010-04-21 07:31:00+0200. The patch is created against current master 
(ec768ed5) and passes all tests.


From ec768ed5659b0e0f91c98a01c981bc359153a7b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=98yvind=20A.=20Holm?= <sunny@sunbase.org>
Date: Wed, 21 Apr 2010 06:21:06 +0200
Subject: [PATCH] date.c: print "1 second ago", not "1 seconds ago"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When using --date=relative, print "1 second ago" instead of "1 seconds
ago".

t0006: Add tests for 0, 1 and 2 seconds ago, to ensure that
--date=relative prints "1 second ago" and "x seconds ago" when x != 1.

Signed-off-by: Øyvind A. Holm <sunny@sunbase.org>
---
 date.c          |    3 ++-
 t/t0006-date.sh |    4 ++++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/date.c b/date.c
index 002aa3c..6aec22b 100644
--- a/date.c
+++ b/date.c
@@ -96,7 +96,8 @@ const char *show_date_relative(unsigned long time, int tz,
 		return "in the future";
 	diff = now->tv_sec - time;
 	if (diff < 90) {
-		snprintf(timebuf, timebuf_size, "%lu seconds ago", diff);
+		snprintf(timebuf, timebuf_size, "%lu second%s ago",
+				diff, (diff != 1 ? "s" : ""));
 		return timebuf;
 	}
 	/* Turn it into minutes */
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index 75b02af..3069545 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -15,6 +15,9 @@ check_show() {
 	"
 }
 
+check_show 0 '0 seconds ago'
+check_show 1 '1 second ago'
+check_show 2 '2 seconds ago'
 check_show 5 '5 seconds ago'
 check_show 300 '5 minutes ago'
 check_show 18000 '5 hours ago'
@@ -48,6 +51,7 @@ check_approxidate() {
 }
 
 check_approxidate now '2009-08-30 19:20:00'
+check_approxidate '1 second ago' '2009-08-30 19:19:59'
 check_approxidate '5 seconds ago' '2009-08-30 19:19:55'
 check_approxidate 5.seconds.ago '2009-08-30 19:19:55'
 check_approxidate 10.minutes.ago '2009-08-30 19:10:00'
-- 
1.7.1.11.g3bf78




Regards,
Øyvind A. Holm
(sunny256)

                 reply	other threads:[~2010-05-08  9:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100508092730.GB26678@triton \
    --to=sunny@sunbase.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).