All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: git@vger.kernel.org
Cc: Yuri Khan <yuri.v.khan@gmail.com>
Subject: [Bug] git-log prints wrong unixtime with --date=format:%s
Date: Tue, 17 May 2016 01:33:33 +0200	[thread overview]
Message-ID: <87vb2d37ea.fsf@web.de> (raw)

Hello,

the command

   git log --pretty=format:%ad --date=format:%s

displays wrong unixtime values; apparently how much the printed value
differs from the expected value depends on the system's time zone and
whether daylight savings time is enabled or not.

Here is a reproducible recipe compiled by Yuri Khan who helped me
localizing the problem and whom I CC'd:

0. Versions

    $ git --version
    git version 2.8.2

    $ dpkg -l tzdata | tail -1
    ii  tzdata  2016d-0ubuntu0.16.04 all  time zone and
daylight-saving time data

1. Initialize an empty Git repository:

    $ git init test
    $ cd test

2. Make a commit, using the Europe/Berlin time zone:

    $ TZ=Europe/Berlin git commit -m 'test' --allow-empty

3. Examine the timestamp recorded in the commit object:

    $ git cat-file -p HEAD | grep author
    author Yuri Khan <yurivkhan@gmail.com> 1463260938 +0200

4. Check that it corresponds to the current time:

    $ date +%s
    1463260977

5. Try to get the commit date in the unixtime format:

    $ TZ=Europe/Berlin git log --pretty=format:%ad --date=format:%s -1

Expected result: 1463260938 (same as recorded in the commit object).
Observed result: 1463264538 (3600s = one hour ahead).

For lulz, use another time zone:

    $ TZ=Asia/Novosibirsk git log --pretty=format:%ad --date=format:%s -1

Expected result: 1463260938 (unixtime is always UTC and should not
depend on TZ).
Observed result: 1463246538 (-14400s = 4 hours behind).

Not even specifying the UTC time zone helps:

    $ TZ=UTC git log --pretty=format:%ad --date=format:%s -1

Expected result: still 1463260938.
Observed result: 1463268138 (7200s = 2 hours ahead).


FWIW, personally I have not bound the TZ environment variable, my time
zone is constantly that of Berlin, currently CEST.

Many thanks in advance,


Michael.

             reply	other threads:[~2016-05-16 23:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 23:33 Michael Heerdegen [this message]
2016-05-17 17:25 ` [Bug] git-log prints wrong unixtime with --date=format:%s 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
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=87vb2d37ea.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=git@vger.kernel.org \
    --cc=yuri.v.khan@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.