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

Re: [Bug] git-log prints wrong unixtime with --date=format:%s

From
Jeff King <peff@peff.net>
Date
May 18, 2016, 00:58 UTC
Message-ID
<20160518005824.GA7120@sigill.intra.peff.net>
In-Reply-To
<20160518004008.GA20007@sigill.intra.peff.net>
On Tue, May 17, 2016 at 08:40:08PM -0400, Jeff King wrote:
Show 5 quoted lines
> So we need some way to tell strftime "...and by the way, this is the
> timezone for the value we are currently feeding you." There isn't a slot
> in "struct tm" for that, but I think maybe you can hack around it by
> setting the global "timezone" variable (and then restoring it
> afterwards).

I tried a few obvious things, but couldn't make anything work. Setting "timezone" manually seems to do nothing. It's supposed to be set by putting the right thing in $TZ and then calling tzset(). So I tried munging $TZ to something like "+0200". It did have _some_ effect, but I couldn't get it to behave correctly in all situations. And using "%z" and "%Z" always just gives GMT.

So I dunno. Perhaps there is some way to coax sane behavior out of strftime, but I could not figure it out. Suggestions welcome.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 4 of 12 in “[Bug] git-log prints wrong unixtime with --date=format:%s”
  1. Michael HeerdegenMay 16, 2016
  2. Michael HeerdegenMay 17, 2016
  3. Jeff KingMay 18, 2016
  4. Jeff KingMay 18, 2016
  5. Junio C HamanoMay 18, 2016
  6. Randall S. BeckerMay 18, 2016
  7. Jeff KingMay 18, 2016
  8. Jeff KingMay 18, 2016
  9. Michael HeerdegenMay 18, 2016
  10. Jeff KingMay 19, 2016
  11. Michael HeerdegenMay 19, 2016
  12. Michael HeerdegenMay 18, 2016

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.