From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Michael Heerdegen <michael_heerdegen@web.de>, git@vger.kernel.org
Subject: Re: [Bug] git-log prints wrong unixtime with --date=format:%s
Date: Wed, 18 May 2016 13:49:19 -0400 [thread overview]
Message-ID: <20160518174919.GA5796@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqvb2bs5f5.fsf@gitster.mtv.corp.google.com>
On Wed, May 18, 2016 at 09:21:34AM -0700, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > I tried a few obvious things, but couldn't make anything work. Setting
> > "timezone" manually seems to do nothing. It's supposed to be set by
> > putting the right thing in $TZ and then calling tzset(). So I tried
> > munging $TZ to something like "+0200". It did have _some_ effect, but I
>
> Wouldn't that be more like "UTC+0200"?
Maybe. I tried several different things, and couldn't make it work
sensibly with any of them. My test case is basically:
git log --format="%ad%n%at" --date=format:'%H:%M %z (%Z)%n%s'
Which should give three lines: the human-readable time and date,
strftime's epoch time, and git's epoch time. And the following
conditions should be met:
1. The human-readable time is in the author's timezone (or the user's
if you use format-local).
2. The zone offset and name in the first line matches the time we
show.
3. The epoch times for the latter lines should match.
We currently get (1) right (which is good, because it is IMHO the most
important). I haven't been able to get (2) to change at all, no matter
what I do. And (3) is the subject of debate here; I suspect I could make
it work at the cost of breaking (1) by giving a "struct tm" that is in
UTC.
> In any case, I do not think anybody wants to do tzset() on each and
> every commit while running "git log". Can we declare "format:<strftime>"
> will always use the local timezone, or something?
I think that is basically the case already. It is in the author's
timezone or in the viewing user's timezone (as reported by localtime()),
and everything seems to work except the %z zone information and the %s
format.
For a raw "%s" date-format, my suggestion is: don't. It is redundant
with --date=raw.
I'd love to make %z work, but I have no idea how.
So I guess we could list those in BUGS in one of the manpages.
-Peff
next prev parent reply other threads:[~2016-05-18 17:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-16 23:33 [Bug] git-log prints wrong unixtime with --date=format:%s Michael Heerdegen
2016-05-17 17:25 ` Michael Heerdegen
2016-05-18 0:40 ` Jeff King
2016-05-18 0:58 ` Jeff King
2016-05-18 16:21 ` Junio C Hamano
2016-05-18 16:44 ` Randall S. Becker
2016-05-18 17:51 ` Jeff King
2016-05-18 17:49 ` Jeff King [this message]
2016-05-18 23:05 ` Michael Heerdegen
2016-05-19 1:54 ` Jeff King
2016-05-19 15:41 ` Michael Heerdegen
2016-05-18 22:57 ` Michael Heerdegen
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=20160518174919.GA5796@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=michael_heerdegen@web.de \
/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).