[ python-Bugs-1053539 ] time module returns wrong timezone under windows

SourceForge.net noreply at sourceforge.net
Mon Oct 25 16:26:54 CEST 2004


Bugs item #1053539, was opened at 2004-10-25 15:41
Message generated for change (Comment added) made by quiver
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1053539&group_id=5470

Category: Python Library
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: panjunyong (panjunyong)
Assigned to: Nobody/Anonymous (nobody)
Summary: time module returns wrong timezone under windows

Initial Comment:
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')


----------------------------------------------------------------------

Comment By: George Yoshida (quiver)
Date: 2004-10-25 23:26

Message:
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.

----------------------------------------------------------------------

Comment By: panjunyong (panjunyong)
Date: 2004-10-25 23:13

Message:
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.

----------------------------------------------------------------------

Comment By: panjunyong (panjunyong)
Date: 2004-10-25 22:56

Message:
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)


----------------------------------------------------------------------

Comment By: panjunyong (panjunyong)
Date: 2004-10-25 22:26

Message:
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


----------------------------------------------------------------------

Comment By: George Yoshida (quiver)
Date: 2004-10-25 22:01

Message:
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."

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1053539&group_id=5470


More information about the Python-bugs-list mailing list