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

Re: :format:%s for date fields seems to be shifted by timezone

From
Jeff King <peff@peff.net>
Date
May 6, 2020, 19:06 UTC
Message-ID
<20200506190651.GA2421358@coredump.intra.peff.net>
In-Reply-To
<CAGqZTUs+xCPjQdeQVfU6EWARmZdjcgcHeSNxkKaTf316rX+8pg@mail.gmail.com>
On Wed, May 06, 2020 at 08:03:52PM +0200, clime wrote:
> what about just printing the raw timestamp from either commit or tag,
> i.e. avoiding any conversion for format:%s?

We don't parse the "%s" ourselves at all. We feed everything after the colon to the system strftime(), and that function only takes a broken-down "struct tm".

That said, we do already intercept "%z" for similar reasons in strbuf_addftime(). So it would probably be possible to declare that we don't respect system "%s" and just handle it ourselves. It would require either massaging the "tm" back to a time_t, or changing the signature to take a redundant time_t (and not all callers might have that).

So if somebody wants to work on a patch in that direction, we could see how ugly it ends up being. But I am reasonably happy with "don't do that" as a solution in the meantime.

-Peff
Previous: clime
Message 4 of 4 in “:format:%s for date fields seems to be shifted by timezone”
  1. climeMay 3, 2020
  2. Jeff KingMay 4, 2020
  3. climeMay 6, 2020
  4. Jeff KingMay 6, 2020

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.