{"thread":{"id":"23543","subject":"[PATCH] date.c: print \"1 second ago\", not \"1 seconds ago\"","startedAt":"2010-04-21T05:31:00Z","lastAt":"2010-04-21T06:35:16Z","messageCount":4,"participants":["Øyvind A. Holm","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"140005","messageId":"1271827860-20947-1-git-send-email-sunny@sunbase.org","threadId":"23543","inReplyTo":null,"subject":"[PATCH] date.c: print \"1 second ago\", not \"1 seconds ago\"","fromName":"Øyvind A. Holm","fromEmail":"sunny@sunbase.org","sentAt":"2010-04-21T05:31:00Z","receivedAt":"2010-04-21T05:31:00Z","isPatch":true,"sender":{"key":"sunny@sunbase.org","avatar":"https://avatars.githubusercontent.com/u/113445?v=4"},"body":"When using --date=relative, print \"1 second ago\" instead of \"1 seconds\nago\".\n\nt0006: Add tests for 0, 1 and 2 seconds ago, to ensure that\n--date=relative prints \"1 second ago\" and \"x seconds ago\" when x != 1.\n\nSigned-off-by: Øyvind A. Holm <sunny@sunbase.org>\n---\n date.c          |    3 ++-\n t/t0006-date.sh |    4 ++++\n 2 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/date.c b/date.c\nindex 002aa3c..6aec22b 100644\n--- a/date.c\n+++ b/date.c\n@@ -96,7 +96,8 @@ const char *show_date_relative(unsigned long time, int tz,\n \t\treturn \"in the future\";\n \tdiff = now->tv_sec - time;\n \tif (diff < 90) {\n-\t\tsnprintf(timebuf, timebuf_size, \"%lu seconds ago\", diff);\n+\t\tsnprintf(timebuf, timebuf_size, \"%lu second%s ago\",\n+\t\t\t\tdiff, (diff != 1 ? \"s\" : \"\"));\n \t\treturn timebuf;\n \t}\n \t/* Turn it into minutes */\ndiff --git a/t/t0006-date.sh b/t/t0006-date.sh\nindex 75b02af..3069545 100755\n--- a/t/t0006-date.sh\n+++ b/t/t0006-date.sh\n@@ -15,6 +15,9 @@ check_show() {\n \t\"\n }\n \n+check_show 0 '0 seconds ago'\n+check_show 1 '1 second ago'\n+check_show 2 '2 seconds ago'\n check_show 5 '5 seconds ago'\n check_show 300 '5 minutes ago'\n check_show 18000 '5 hours ago'\n@@ -48,6 +51,7 @@ check_approxidate() {\n }\n \n check_approxidate now '2009-08-30 19:20:00'\n+check_approxidate '1 second ago' '2009-08-30 19:19:59'\n check_approxidate '5 seconds ago' '2009-08-30 19:19:55'\n check_approxidate 5.seconds.ago '2009-08-30 19:19:55'\n check_approxidate 10.minutes.ago '2009-08-30 19:10:00'\n-- \n1.7.1.rc2.5.gddd02\n"},{"id":"140006","messageId":"4BCE977D.9040700@viscovery.net","threadId":"23543","inReplyTo":"1271827860-20947-1-git-send-email-sunny@sunbase.org","subject":"Re: [PATCH] date.c: print \"1 second ago\", not \"1 seconds ago\"","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-04-21T06:13:17Z","receivedAt":"2010-04-21T06:13:17Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 4/21/2010 7:31, schrieb Øyvind A. Holm:\n> When using --date=relative, print \"1 second ago\" instead of \"1 seconds\n> ago\".\n\nWhy do you care only about about \"1 seconds\", but not \"1 minutes\", \"1\nhours\", etc? I mean, \"1 seconds ago\" is the most unlikely case of them all\nthat will happen in practice...\n\n-- Hannes\n"},{"id":"140007","messageId":"i2jc4c738cd1004202328hb58859f8ze9eb1858f5493c66@mail.gmail.com","threadId":"23543","inReplyTo":"4BCE977D.9040700@viscovery.net","subject":"Re: [PATCH] date.c: print \"1 second ago\", not \"1 seconds ago\"","fromName":"Øyvind A. Holm","fromEmail":"sunny@sunbase.org","sentAt":"2010-04-21T06:28:47Z","receivedAt":"2010-04-21T06:28:47Z","isPatch":true,"sender":{"key":"sunny@sunbase.org","avatar":"https://avatars.githubusercontent.com/u/113445?v=4"},"body":"On 21 April 2010 08:13, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 4/21/2010 7:31, schrieb Øyvind A. Holm:\n>> When using --date=relative, print \"1 second ago\" instead of \"1 seconds\n>> ago\".\n>\n> Why do you care only about about \"1 seconds\", but not \"1 minutes\", \"1\n> hours\", etc? I mean, \"1 seconds ago\" is the most unlikely case of them all\n> that will happen in practice...\n\nIt will never show \"1 minute\", \"1 hour\", etc. Only\n\n  - \"89 minutes\" → \"2 hours\"\n  - \"35 hours\" → \"2 days\"\n  - \"13 days\" → \"2 weeks\"\n\nand so on. Seconds is the only thing left to fix.\n\nCheers,\nØyvind A. Holm\n(sunny256)\n"},{"id":"140009","messageId":"4BCE9CA4.6010208@viscovery.net","threadId":"23543","inReplyTo":"i2jc4c738cd1004202328hb58859f8ze9eb1858f5493c66@mail.gmail.com","subject":"Re: [PATCH] date.c: print \"1 second ago\", not \"1 seconds ago\"","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-04-21T06:35:16Z","receivedAt":"2010-04-21T06:35:16Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 4/21/2010 8:28, schrieb Øyvind A. Holm:\n> It will never show \"1 minute\", \"1 hour\", etc.\n\nI see, thanks.\n\n-- Hannes\n"}]}