From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: "Git Mailing List" <git@vger.kernel.org>,
"Ulrich Mueller" <ulm@gentoo.org>,
"Junio C Hamano" <gitster@pobox.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Johannes Schindelin" <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v3] strbuf: let strbuf_addftime handle %z and %Z itself
Date: Thu, 15 Jun 2017 09:49:58 -0400 [thread overview]
Message-ID: <20170615134958.mzmdmhonjsnconu2@sigill.intra.peff.net> (raw)
In-Reply-To: <5f398cf6-2bc3-f999-acfa-0ef6d7a43435@web.de>
On Thu, Jun 15, 2017 at 02:29:53PM +0200, René Scharfe wrote:
> There is no portable way to pass timezone information to strftime. Add
> parameters for timezone offset and name to strbuf_addftime and let it
> handle the timezone-related format specifiers %z and %Z internally.
>
> Callers can opt out for %Z by passing NULL as timezone name. %z is
> always handled internally -- this helps on Windows, where strftime would
> expand it to a timezone name (same as %Z), in violation of POSIX.
> Modifiers are not handled, e.g. %Ez is still passed to strftime.
>
> Use an empty string as timezone name in show_date (the only current
> caller) for now because we only have the timezone offset in non-local
> mode. POSIX allows %Z to resolve to an empty string in case of missing
> information.
>
> Helped-by: Ulrich Mueller <ulm@gentoo.org>
> Helped-by: Jeff King <peff@peff.net>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> Changes from v3:
> - Updated developer documentation in strbuf.h.
> - Added short note to user documentation.
This looks good to me overall.
> diff --git a/t/t0006-date.sh b/t/t0006-date.sh
> index 42d4ea61ef..71082008f0 100755
> --- a/t/t0006-date.sh
> +++ b/t/t0006-date.sh
> @@ -51,6 +51,12 @@ check_show iso-local "$TIME" '2016-06-15 14:13:20 +0000'
> check_show raw-local "$TIME" '1466000000 +0000'
> check_show unix-local "$TIME" '1466000000'
>
> +check_show 'format:%z' "$TIME" '+0200'
> +check_show 'format-local:%z' "$TIME" '+0000'
> +check_show 'format:%Z' "$TIME" ''
> +check_show 'format:%%z' "$TIME" '%z'
> +check_show 'format-local:%%z' "$TIME" '%z'
These check that the zone output is correct, but I don't think we ever
check that the value we feed to strftime is actually in the correct zone
in the first place (i.e., that %H shows the correct time).
I think that should go in a separate test from the %z/%Z handling, as
there are some subtleties.
So here are two patches on top of yours: more tests, and then the
format-local handling of %Z.
[1/2]: t0006: check --date=format zone offsets
[2/2]: date: use localtime() for "-local" time formats
date.c | 14 ++++++++++++--
t/t0006-date.sh | 10 ++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)
-Peff
next prev parent reply other threads:[~2017-06-15 13:50 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
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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170615134958.mzmdmhonjsnconu2@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=l.s.r@web.de \
--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.
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 NNTP newsgroup(s).