[ python-Bugs-902172 ] Timezone miscalculation (time.mktime)

SourceForge.net noreply at sourceforge.net
Sun Feb 22 11:11:51 EST 2004


Bugs item #902172, was opened at 2004-02-22 18:09
Message generated for change (Comment added) made by sipsick
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=902172&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Marti Raudsepp (sipsick)
Assigned to: Nobody/Anonymous (nobody)
Summary: Timezone miscalculation (time.mktime)

Initial Comment:
The problem:
time.mktime(time.gmtime(0)) - time.timezone == -3600.
0
(Should be 0.0 if I understood it right)

Python seems to miscalculate the local time when using 
mktime. The problem appeared when one of the runtests 
in MoinMoin failed (spefically MoinMoin._tests.
test_parser_wiki.WikiMacroTestCase)

I used two machines for testing:
1. NetBSD 1.6.1 (GENERIC), Python version 2.3.3 (#1, 
Feb 20 2004, 00:53:29) [GCC 2.95.3 20010315 (release) 
(NetBSD nb3)]
2. Linux 2.4.20-3-686 (Debian GNU/Linux), Python 
version 2.3.3 (#2, Jan 13 2004, 00:47:05) [GCC 3.3.3 
20040110 (prerelease) (Debian)]

Both machine generate the identical error:
AssertionError: Expected '1#1970-01-06 00:00:00#1' in:
1#1970-01-05 23:00:00#1 [...]

A few simple tests in the python shell (both machines)
>>> import time
>>> time.daylight
1
>>> time.timezone
-7200
>>> time.tzname
('EET', 'EEST')
>>> time.mktime(time.localtime(0))
0.0
>>> time.mktime(time.gmtime(0)) - time.timezone
-3600.0
>>> time.gmtime(0)
(1970, 1, 1, 0, 0, 0, 3, 1, 0)
>>> time.mktime((1970, 1, 1, 0, 0, 0, 3, 1, 0)) - time.
timezone
-3600.0
>>> time.mktime((1970, 1, 1, 0, 0, 0, 3, 1, -1)) - time.
timezone
-3600.0


However, the only difference between the Linux and BSD 
machine is:
1. NetBSD
>>> time.mktime((1970, 1, 1, 0, 0, 0, 3, 1, 1)) - time.
timezone
-7200.0
2. Linux
>>> time.mktime((1970, 1, 1, 0, 0, 0, 3, 1, 1)) - time.
timezone
-3600.0

I also attached the results of the moin test just in case.

--
Marti

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

>Comment By: Marti Raudsepp (sipsick)
Date: 2004-02-22 18:11

Message:
Logged In: YES 
user_id=345221

There's no uploaded file!  You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.

Please try again.

(This is a SourceForge annoyance that we can do
nothing about. :-( )

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

Comment By: Marti Raudsepp (sipsick)
Date: 2004-02-22 18:11

Message:
Logged In: YES 
user_id=345221

Oops, forgot to check the upload box :)

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

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



More information about the Python-bugs-list mailing list