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

Re: [PATCH] strbuf_addftime(): handle "%s" manually

From
Jeff King <peff@peff.net>
Date
Nov 4, 2021, 02:11 UTC
Message-ID
<YYNBOp4QDwG9ctHE@coredump.intra.peff.net>
In-Reply-To
<xmqqtugt56i7.fsf@gitster.g>
On Wed, Nov 03, 2021 at 01:28:00PM -0700, Junio C Hamano wrote:
Show 18 quoted lines
> I think this also needs squashing in?
> 
>  Documentation/rev-list-options.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git c/Documentation/rev-list-options.txt w/Documentation/rev-list-options.txt
> index 24569b06d1..43a86fa562 100644
> --- c/Documentation/rev-list-options.txt
> +++ w/Documentation/rev-list-options.txt
> @@ -1047,7 +1047,7 @@ omitted.
>  has no effect.
>  
>  `--date=format:...` feeds the format `...` to your system `strftime`,
> -except for %z and %Z, which are handled internally.
> +except for %s, %z, and %Z, which are handled internally.
>  Use `--date=format:%c` to show the date in your system locale's
>  preferred format.  See the `strftime` manual for a complete list of
>  format placeholders. When using `-local`, the correct syntax is

Ah, thanks. I didn't even think to look in the documentation, because I didn't imagine that we would expose these implementation details. But since we do mention %z there, I think adding %s makes sense.

BTW, I also noticed that stftime supports some locale modifiers. So "%Es" ends up printing the epoch seconds, but eludes our manual intervention (and so does the old, wrong thing). I'm fine with stopping here, though. There's no reason to use %Es over %s (from what I gather, the %E is about handling year eras for locales that support them, but that's meaningless for an epoch time), and I'm not sure it is even a portable thing (glibc does not mention it in the manpage along with other %E values, but it does work; POSIX does not even define %s, so of course does not mention %Es).

-Peff
Previous: Junio C Hamano
Message 12 of 12 in “timezone related bug of git”
  1. Dongsheng SongOct 31, 2021
  2. Jeff KingOct 31, 2021
  3. Dongsheng SongOct 31, 2021
  4. Junio C HamanoOct 31, 2021
  5. Jeff KingNov 1, 2021
  6. Dongsheng SongNov 1, 2021
  7. Junio C HamanoNov 1, 2021
  8. Jeff KingNov 2, 2021
  9. strbuf_addftime(): handle "%s" manuallyJeff King, Nov 2, 2021
  10. Jeff KingNov 2, 2021
  11. Junio C HamanoNov 3, 2021
  12. Jeff KingNov 4, 2021

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.