开发者

Python's fromtimestamp returns inconsistent results on different machines

I have two computers, for the first one:

>>> datetime.datetime.fromtimestamp(0)
datetime.datetime(1970, 1, 1, 7, 30)
>>> datetime.datetime.fromtimestamp(1309846824)
datetime.datetime(2011, 7, 5, 14, 2开发者_StackOverflow社区0, 24)

for the second one:

>>> datetime.datetime.fromtimestamp(0)
datetime.datetime(1970, 1, 1, 8, 0)
>>> datetime.datetime.fromtimestamp(1309846824)
datetime.datetime(2011, 7, 5, 14, 20, 24)

How could they differ on '0' while agreeing on '1309846824'?


Here is an excerpt from the "asia" file that tzdata uses. On debian/ubuntu you can get this file by running the command apt-get source tzdata

...
# Zone  NAME            GMTOFF  RULES   FORMAT  [UNTIL]
Zone Asia/Kuala_Lumpur  6:46:46 -       LMT     1901 Jan  1
                        6:55:25 -       SMT     1905 Jun  1 # Singapore M.T.
                        7:00    -       MALT    1933 Jan  1 # Malaya Time
                        7:00    0:20    MALST   1936 Jan  1
                        7:20    -       MALT    1941 Sep  1
                        7:30    -       MALT    1942 Feb 16
                        9:00    -       JST     1945 Sep 12
                        7:30    -       MALT    1982 Jan  1
                        8:00    -       MYT     # Malaysia Time
...

This describes how the timezone of Kuala Lumpur has changed since 1901. So in 1970 we see it was GMT+7.5 now it is GMT+8

Windows doesn't use any form of tzdata, so only knows the current offset

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜