From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Ulrich Mueller <ulm@gentoo.org>, Git Mailing List <git@vger.kernel.org>
Subject: Re: git-2.13.0: log --date=format:%z not working
Date: Sun, 28 May 2017 12:29:22 +0200 [thread overview]
Message-ID: <CACBZZX6zG0z90coXz_Xzqvdp+9LpJ4RE2dAJggfLL-nd0nkWVQ@mail.gmail.com> (raw)
In-Reply-To: <20170527214611.suohggo226tvmbgt@sigill.intra.peff.net>
On Sat, May 27, 2017 at 11:46 PM, Jeff King <peff@peff.net> wrote:
> On Sat, May 27, 2017 at 06:57:08PM +0200, Ævar Arnfjörð Bjarmason wrote:
>
>> There's another test which breaks if we just s/gmtime/localtime/g. As
>> far as I can tell to make the non-local case work we'd need to do a
>> whole dance where we set the TZ variable to e.g. UTC$offset, then call
>> strftime(), then call it again. Maybe there's some way to just specify
>> the tz offset, but I didn't find any in a quick skimming of time.h.
>
> There isn't. At least on _some_ platforms, the zone information is
> embedded in "struct tm" and stored by gmtime() and localtime(), but the
> fields aren't publicly accessible. Which is why your patch worked for
> format-local (it swaps out gmtime() for localtime() which sets those
> fields behind the scenes). But:
>
> - I'm not sure that's guaranteed by the standard; strftime() might get
> its zone information elsewhere (if it needs to reliably distinguish
> between gmtime() and localtime() results it has to at least set a
> bit in the "struct tm", but that bit may not be the full zone info).
>
> - Even if it does work, you're stuck with only the local timezone. In
> theory you could temporarily tweak the process's timezone, call
> localtime(), and then tweak it back. I was never able to get that to
> work (links below).
>
> On glibc, at least, you can access the zone fields in "struct tm" by
> compiling with _DEFAULT_SOURCE.
>
> So I think the best we could do is probably to have a feature macro like
> TM_HAS_GMTOFF, and set tm->tm_gmtoff and tm->tm_zone on platforms that
> support it. I'm not sure what we'd put in the latter, though; we don't
> actually have the timezone name at all (we just have "+0200" or whatever
> we parsed from the git object, but that would be better than nothing).
>
> That leaves other platforms still broken, but like I said, I don't think
> there's a portable solution.
>
> Here are some links to past explorations:
>
> http://public-inbox.org/git/20160208152858.GA17226@sigill.intra.peff.net/
>
> http://public-inbox.org/git/87vb2d37ea.fsf@web.de/
There's a third and possibly least shitty option that isn't covered in
those threads; We could just make a pass over the strftime format
ourselves and replace %z and %Z with the timezone (as done for
DATE_ISO8601_STRICT in date.c), then hand the rest off to strftime().
I'm not going to pursue it though, Ulrich, are you maybe interested in
hacking on that?
next prev parent reply other threads:[~2017-05-28 10:29 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-26 18:33 git-2.13.0: log --date=format:%z not working Ulrich Mueller
2017-05-27 16:57 ` Ævar Arnfjörð Bjarmason
2017-05-27 21:46 ` Jeff King
2017-05-28 10:29 ` Ævar Arnfjörð Bjarmason [this message]
2017-05-29 0:53 ` Junio C Hamano
2017-05-28 11:43 ` René Scharfe
2017-06-02 2:23 ` Junio C Hamano
2017-06-02 3:08 ` Jeff King
2017-06-02 17:25 ` René Scharfe
2017-06-02 18:35 ` Jeff King
2017-06-02 22:04 ` Ulrich Mueller
2017-06-02 22:30 ` Jeff King
2017-06-02 22:47 ` Ulrich Mueller
2017-06-02 22:51 ` Jeff King
2017-06-03 10:40 ` [PATCH] strbuf: let strbuf_addftime handle %z and %Z itself René Scharfe
2017-06-03 13:13 ` Ulrich Mueller
2017-06-03 16:20 ` René Scharfe
2017-06-07 8:17 ` Jeff King
2017-06-07 9:13 ` [PATCH] date: use localtime() for "-local" time formats Jeff King
2017-06-11 17:36 ` [PATCH] strbuf: let strbuf_addftime handle %z and %Z itself René Scharfe
2017-06-12 15:12 ` Junio C Hamano
2017-06-12 16:16 ` Ævar Arnfjörð Bjarmason
2017-06-12 16:56 ` Ulrich Mueller
2017-06-12 17:53 ` Ævar Arnfjörð Bjarmason
2017-06-12 18:15 ` Junio C Hamano
2017-06-12 18:20 ` Jeff King
2017-06-12 19:02 ` Ævar Arnfjörð Bjarmason
2017-06-12 21:10 ` Jeff King
2017-06-13 6:23 ` Linus Torvalds
2017-06-12 22:31 ` René Scharfe
2017-06-13 10:16 ` Ævar Arnfjörð Bjarmason
2017-06-13 10:31 ` Ulrich Mueller
2017-06-12 16:58 ` René Scharfe
2017-06-12 17:36 ` Jeff King
2017-06-15 8:46 ` [PATCH v2] " René Scharfe
2017-06-15 11:27 ` Ulrich Mueller
2017-06-15 12:28 ` René Scharfe
2017-06-15 12:29 ` [PATCH v3] " René Scharfe
2017-06-15 13:49 ` Jeff King
2017-06-15 13:51 ` [PATCH 1/2] t0006: check --date=format zone offsets Jeff King
2017-06-15 13:52 ` [PATCH 2/2] date: use localtime() for "-local" time formats Jeff King
2017-06-15 16:12 ` René Scharfe
2017-06-15 21:40 ` Junio C Hamano
2017-06-16 12:18 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACBZZX6zG0z90coXz_Xzqvdp+9LpJ4RE2dAJggfLL-nd0nkWVQ@mail.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=ulm@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).