git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: approxidate woes

From
Jeff King <peff@peff.net>
Date
Nov 15, 2018, 14:54 UTC
Message-ID
<20181115145407.GC16450@sigill.intra.peff.net>
In-Reply-To
<20181115144854.GB16450@sigill.intra.peff.net>
On Thu, Nov 15, 2018 at 09:48:54AM -0500, Jeff King wrote:
Show 10 quoted lines
> I don't think "48h" does what you expect either:
> 
>   $ t/helper/test-date approxidate now
>   now -> 2018-11-15 14:43:32 +0000
> 
>   $ t/helper/test-date approxidate 48h
>   48h -> 2018-11-15 14:43:34 +0000
> 
>   $ t/helper/test-date approxidate 48.hours
>   48.hours -> 2018-11-13 14:43:38 +0000
Whoops, those should all be:
  t/helper/test-tool date approxidate ...

in recent versions of Git (I was bisecting something earlier, and has a crufty test-date left over from an old version!).

Adding new unit aliases would be something like:
diff --git a/date.c b/date.c
index 9bc15df6f9..eb477d1601 100644
--- a/date.c
+++ b/date.c
@@ -1016,6 +1016,7 @@ static const struct typelen {
 	{ "minutes", 60 },
 	{ "hours", 60*60 },
 	{ "days", 24*60*60 },
+	{ "d", 24*60*60 },
 	{ "weeks", 7*24*60*60 },
 	{ NULL }
 };

but I suspect we need to tighten up the string matching a bit. I think
that would allow "2 dogs" to be parsed as "days".

-Peff
Previous: Jeff King
Message 3 of 3 in “approxidate woes”
  1. Andreas KreyNov 15, 2018
  2. Jeff KingNov 15, 2018
  3. Jeff KingNov 15, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.