git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: John Keeping <john@keeping.me.uk>
Cc: git@vger.kernel.org
Subject: Re: Timezone with DATE_STRFTIME
Date: Mon, 8 Feb 2016 10:28:58 -0500	[thread overview]
Message-ID: <20160208152858.GA17226@sigill.intra.peff.net> (raw)
In-Reply-To: <20160208143317.GN29880@serenity.lan>

On Mon, Feb 08, 2016 at 02:33:17PM +0000, John Keeping wrote:

> I have just noticed that with DATE_STRFTIME, the timezone in the output
> is likely to be incorrect.
> 
> For all other time formats, we print the string ourselves and use the
> correct timezone from the input, but with DATE_STRFTIME strftime(3) will
> always use the system timezone.

You mean here that the "%z" formatting will not be correct, right?
AFAICT the time shown is generally correct for the original of the
author, and we simply need to communicate the zone to strftime.

Taking the current tip of master, for instance, I get:

  $ for i in \
      default \
      local \
      "format:%H:%M %z" \
      "format-local:%H:%M %z"; do
            git log -1 --format=%ad --date="$i" ff4ea6004
    done
  Fri Feb 5 15:24:02 2016 -0800
  Fri Feb 5 18:24:02 2016
  15:24 +0000
  18:24 +0000

You can see that my system is in -0500, three hours ahead of the author.
And as expected, strftime shows the time in the original author's
timezone. The %z information is totally bogus, but I don't think it has
anything to do with the system time. It is simply that we don't provide
it (...but having just looked at _your_ local timezone from your email,
I can guess how you got confused :) ).

So I think the fix is probably just that we need to feed the zone
information to strftime via the "struct tm".

-Peff

  reply	other threads:[~2016-02-08 15:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 14:33 Timezone with DATE_STRFTIME John Keeping
2016-02-08 15:28 ` Jeff King [this message]
2016-02-08 15:44   ` Jeff King
2016-02-08 15:46   ` John Keeping

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=20160208152858.GA17226@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=john@keeping.me.uk \
    /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).