git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ulrich Mueller <ulm@gentoo.org>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"René Scharfe" <l.s.r@web.de>, "Jeff King" <peff@peff.net>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH] strbuf: let strbuf_addftime handle %z and %Z itself
Date: Mon, 12 Jun 2017 18:56:34 +0200	[thread overview]
Message-ID: <22846.51138.555606.729612@a1i15.kph.uni-mainz.de> (raw)
In-Reply-To: <CACBZZX5ofJC70S09rfL_EMK2KWAoPCMun1eisi+CXeX=FSwy6Q@mail.gmail.com>

>>>>> On Mon, 12 Jun 2017, Ævar Arnfjörð Bjarmason wrote:

> On Mon, Jun 12, 2017 at 5:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> René Scharfe <l.s.r@web.de> writes:
>>> Yes, or you could look up a time zone name somewhere else -- except we
>>> don't have a way to do that, at least for now.
>> 
>> Is that only "for now"?  I have a feeling that it is fundamentally
>> impossible with the data we record.  When GMTOFF 9:00 is the only
>> thing we have for a timestamp, can we tell if we should label it as
>> JST (aka Asia/Tokyo) or KST (aka Asia/Seoul)?

> It's obviously not perfect for all the reasons mentioned in this
> thread, but we already have a timezone->offset mapping in the
> timezone_names variable in date.c, a good enough solution might be to
> simply reverse that lookup when formatting %Z

That cannot work, because there is no unique mapping from offset to
timezone name. For a given offset there may be several timezone names,
or no name at all. (For example, if I decide to commit with my local
mean time which has an offset of +0033 then there won't be any
timezone name at all.)

> Of course we can never know if you were in Tokyo or Seul from the info
> in the commit object, but we don't need to, it's enough that we just
> emit JST for +0900 and anyone reading the output has at least some
> idea what +0900 maps to.

Please don't. Outputting invented information for something that
really isn't in the data is worse than outputting no information at
all.

> We could also simply replace "%Z" with the empty string, as the the
> POSIX strftime() documentation allows for:
> http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
> ("Replaced by the timezone name or abbreviation, or by no bytes if no
> timezone information exists.").

IMHO the two viable possibilities are the empty string, or the same
information as for %z. But this has been said before in this thread.

tzdata2017b has the following data in its "etcetera" file, the last
column being the timezone name:

   Zone	    Etc/GMT 	     0	-    GMT

   Zone	    Etc/GMT-14	    14	-    +14
   Zone	    Etc/GMT-13	    13	-    +13
   [...]
   Zone	    Etc/GMT+12	   -12	-    -12

This would be at least some rationale for converting %Z to [+-]hhmm,
i.e., the same as for %z. (One could even think about [+-]hh if the
minutes part is zero, but this already looks like over-engineering
to me.)

Ulrich

  reply	other threads:[~2017-06-12 16:56 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
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 [this message]
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=22846.51138.555606.729612@a1i15.kph.uni-mainz.de \
    --to=ulm@gentoo.org \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    /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).