[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Time zone trouble without time zones being involved
From: |
Yuri Khan |
Subject: |
Re: Time zone trouble without time zones being involved |
Date: |
Sun, 15 May 2016 03:51:43 +0600 |
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).