From: Yuri Khan <yuri.v.khan@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: Time zone trouble without time zones being involved
Date: Sun, 15 May 2016 03:51:43 +0600 [thread overview]
Message-ID: <CAP_d_8VibNd2yX8rar+DQGfSQb__yFHDbksZV7SMi9N2XcANTw@mail.gmail.com> (raw)
In-Reply-To: <87a8js8oa8.fsf@web.de>
On Sun, May 15, 2016 at 12:53 AM, Michael Heerdegen
<michael_heerdegen@web.de> wrote:
> Here are the results. It is 20:44 here now after I run the tests
> (Central European Daylight savings time, the time zone of Berlin).
So, UTC+1 in winter, UTC+2 in summer.
>> 1. Mark the current UTC time, both as a human-readable string and as a
>> unixtime value (e.g. on GNU, “date --utc --rfc-3339=seconds” and “date
>> +%s”, respectively).
>
> date --utc --rfc-3339=seconds => 2016-05-14 18:38:17+00:00
> date +%s => 1463251129
The unixtime works out to 2016-05-14 18:38:49+00:00, consistent with
the UTC time. Also consistent with your wall clock considering the
UTC+2 offset.
>> 2. Make a commit. 3. Execute the same command, “git log
>> --pretty=format:%ad --date=format:%s -n1”.
>
> 1463254759
1463254759 - 1463251129 = 3630 seconds, or 1 hour 30 seconds.
Does “git cat-file commit HEAD” show the same number in the “author” line?
>> 4. Evaluate (current-time) and convert the first two elements of the
>> resulting 4-element list to unixtime.
>
> (let ((time (current-time))) (+ (* 65536 (car time)) (cadr time)))
> ==> 1463251305
176 seconds from step 1.
> Looks like git is 1 hour wrong...?
Yes.
Here’s a repeatable recipe. You can report it as a Git bug.
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).
next prev parent reply other threads:[~2016-05-14 21:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-03 6:11 Time zone trouble without time zones being involved Michael Heerdegen
2016-04-03 6:43 ` Yuri Khan
2016-04-13 16:14 ` Michael Heerdegen
2016-04-13 16:48 ` Yuri Khan
2016-04-13 17:16 ` Michael Heerdegen
2016-04-13 17:40 ` Yuri Khan
2016-05-14 18:53 ` Michael Heerdegen
2016-05-14 21:51 ` Yuri Khan [this message]
2016-05-16 15:47 ` Michael Heerdegen
2016-05-16 16:06 ` Yuri Khan
2016-05-17 14:57 ` Michael Heerdegen
2016-05-17 15:31 ` Yuri Khan
2016-05-17 16:19 ` 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=CAP_d_8VibNd2yX8rar+DQGfSQb__yFHDbksZV7SMi9N2XcANTw@mail.gmail.com \
--to=yuri.v.khan@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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.