This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: time module returns wrong timezone under windows
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, panjunyong, quiver, tim.peters
Priority: normal Keywords:

Created on 2004-10-25 06:41 by panjunyong, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (10)
msg22833 - (view) Author: panjunyong (panjunyong) Date: 2004-10-25 06:41
I have tested windows xp/2000 Chinese version with
python 2.3.3 and python 2.4b1.  

My timezone in windows is GMT+8. But:

>>> import time
>>> time.timezone
-28800 

-28800 means GMT-8, but not GMT+8. This cause
time.time() time.gmtime() return wrong values(16 hours
late).

I have no such problem under linux.

BTW, I found the issue:

https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1039270&group_id=5470


So I think maybe this problem is sensitive with my
Chinese platform too:

>>> time.tzname
('\xd6\xd0\xb9\xfa\xb1\xea\xd7\xbc\xca\xb1\xbc\xe4',
'\xd6\xd0\xb9\xfa\xb1\xea\x
d7\xbc\xca\xb1\xbc\xe4')
msg22834 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2004-10-25 13:01
Logged In: YES 
user_id=671362

> -28800 means GMT-8
No, look at the doc more carefully.
  www.python.org/doc/current/lib/module-time.html
  negative in most of Western Europe, positive in the US, zero 
in the UK
If I remember correctly, China is on the opposite side of the 
world from the US. :-)

> time.time() time.gmtime() return wrong values(16 hours
> late).
Reverify the time-zone with your Windows machine.

BTW, "Most-of-Western-Europe" doesn't seem clear to me at 
all.
What's wrong with:
"negative in Asia, positive in the US, zero in the UK."
msg22835 - (view) Author: panjunyong (panjunyong) Date: 2004-10-25 13:26
Logged In: YES 
user_id=601368

I am sure with my windows timezone setting. The time.tzname
is Chinese, which means 'Chinese Standard Time'. And China
is in GMT+8 zone.

Everything is ok under linux:

>>> import time
>>> time.tzname
('GMT+8', 'GMT+8')
>>> time.timezone
28800
msg22836 - (view) Author: panjunyong (panjunyong) Date: 2004-10-25 13:56
Logged In: YES 
user_id=601368

Sorry, time should be right under Windows(my mistake :-( ).
Then since the result is quite different, maybe time is
wrong under Linux? 

windows:

>>> import time
>>> time.timezone
-28800
>>> time.localtime()
(2004, 10, 25, 21, 28, 24, 0, 299, 0)
>>> time.gmtime()
(2004, 10, 25, 13, 28, 29, 0, 299, 0)

And Linux:

>>> import time
>>> time.timezone
28800
>>> time.tzname
('GMT+8', 'GMT+8')
>>> time.localtime()
(2004, 10, 25, 21, 28, 6, 0, 299, 0)
>>> time.gmtime()
(2004, 10, 26, 5, 28, 10, 1, 300, 0)
msg22837 - (view) Author: panjunyong (panjunyong) Date: 2004-10-25 14:13
Logged In: YES 
user_id=601368

Oh, is this a linux bug? See these two commands under linux:

# date
Mon Oct 25 22:06:58 GMT+8 2004
# date -u
Tue Oct 26 06:06:59 UTC 2004

the UTC time should be wrong.
msg22838 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2004-10-25 14:26
Logged In: YES 
user_id=671362

> Oh, is this a linux bug? 
Looks like. On my box,
$ date
Mon Oct 25 23:20:26 JST 2004
$ date -u
Mon Oct 25 14:20:27 UTF 2004

Just out of curiosity,  what's your /proc/version?
You just say Linux, and don't give any further info.
msg22839 - (view) Author: panjunyong (panjunyong) Date: 2004-10-25 14:39
Logged In: YES 
user_id=601368

sorry, here is my linux /pro/version:

# more /proc/version
Linux version 2.4.25-1 (gcc version 3.3.3 (Debian
)) #1 SMP Wed Mar 10 13:10:05 GMT+8 2004

and more about date:

# date +%Z
GMT+8
# date +%z
-0800
msg22840 - (view) Author: panjunyong (panjunyong) Date: 2004-10-25 14:53
Logged In: YES 
user_id=601368

Oh, I should set my linux time zone to GMT-8, which
represent the zone +0800, but not GMT+8. This is quite strange. 

I learn it from this:

http://lists.debian.org/debian-chinese-gb/2002/07/msg00063.html

Thanks for your kind. 
msg22841 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-10-25 14:55
Logged In: YES 
user_id=31435

Closing as invalid, since there doesn't appear to be a Python 
bug here.
msg22842 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2004-11-06 20:19
Logged In: YES 
user_id=357491

Setting the status/resolution back to what Tim had them to.
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41071
2004-10-25 06:41:18panjunyongcreate