[ python-Bugs-1656559 ] I think, I have found this bug on time.mktime()

SourceForge.net noreply at sourceforge.net
Tue Feb 13 16:54:05 CET 2007


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

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
>Group: 3rd Party
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Sérgio Monteiro Basto (sergiomb)
Assigned to: Nobody/Anonymous (nobody)
Summary: I think, I have found this bug on time.mktime()

Initial Comment:
well, I think, I have found this bug on time.mktime() for dates less
than 1976-09-26

when I do stringtotime of 1976-09-25 

print "timeint %d" % time.mktime(__extract_date(m) + __extract_time(m) + (0, 0, 0)) 

extract date = 1976 9 25
extract time = 0 0 0
timeint 212454000
and 
timetostring(212454000) = 1976-09-24T23:00:00Z !? 

To be honest the date that kept me the action was the 1-1-1970 that
appears 31-12-1969. After timetostring(stringtotime(date)))

I made the test and time.mktime got a bug when date is less than
1976-09-26 
see:
for 1976-09-27T00:00:00Z time.mktime gives 212630400
for 1976-09-26T00:00:00Z time.mktime gives 212544000
for 1976-09-25T00:00:00Z time.mktime gives 212454000

212630400 - 212544000 = 86400 (seconds) , one day correct !
but
212544000 - 212454000 = 90000 (seconds), one day more 3600 (seconds),
more one hour ?!? 
    
--
Sérgio M. B. 



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

>Comment By: Martin v. Löwis (loewis)
Date: 2007-02-13 16:54

Message:
Logged In: YES 
user_id=21627
Originator: NO

cvalente, thanks for the research. Making a second attempt at closing this
as third-party bug.

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

Comment By: Sérgio Monteiro Basto (sergiomb)
Date: 2007-02-13 15:25

Message:
Logged In: YES 
user_id=4882
Originator: YES

ok bug openned on 
http://sources.redhat.com/bugzilla/show_bug.cgi?id=4033

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

Comment By: Claudio Valente (cvalente)
Date: 2007-02-13 13:47

Message:
Logged In: YES 
user_id=627298
Originator: NO

OK. This is almost surely NOT a Python bug but most likely a libc bug.

In c:
----------
#include <time.h>
#include <stdio.h>

int main(int argc, char* argv[]){
        struct tm t1;
        struct tm t2;

        /* midnight 26/SET/1076*/
        t1.tm_sec  = 0;
        t1.tm_min  = 0;
        t1.tm_hour = 0;
        t1.tm_mday = 26;
        t1.tm_mon  = 8;
        t1.tm_year = 76;

        /* midnight 25/SET/1076*/
        t2.tm_sec  = 0;
        t2.tm_min  = 0;
        t2.tm_hour = 0;
        t2.tm_mday = 25;
        t2.tm_mon  = 8;
        t2.tm_year = 76;

        printf("%li\n", mktime(&t1)-mktime(&t2));
        printf("%li\n", mktime(&t1)-mktime(&t2));

        return 0;
}
------
Outputs:

90000
86400


In perl:
-----
perl -le 'use POSIX; $t1=POSIX::mktime(0,0,0,26,8,76)
-POSIX::mktime(0,0,0,25,8,76); $t2 = POSIX::mktime(0,0,0,26,8,76)
-POSIX::mktime(0,0,0,25,8,76) ; print $t1."\n". $t2'
-----

Outputs

90000
86400

-----

My system is gentoo with glibc 2.4-r4
and my timezone is:
/usr/share/zoneinfo/Europe/Lisbon

When I changed this to another timezone (Say London) the problem didn't
exist.

Thank you all for your time.

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

Comment By: Sérgio Monteiro Basto (sergiomb)
Date: 2007-02-13 13:22

Message:
Logged In: YES 
user_id=4882
Originator: YES

timezone :  WET in winter WEST in summer 
I try same with timezone of NEW YORK and 
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
86400.0


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

Comment By: Claudio Valente (cvalente)
Date: 2007-02-13 13:07

Message:
Logged In: YES 
user_id=627298
Originator: NO

I have the smae problem.

My system info is:
Python 2.4.3 (#1, Oct 18 2006, 16:42:32)
[GCC 4.1.1 (Gentoo 4.1.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.


my libc version is 2.4-r4.

I'll try to run the analogous program in C and see whether this is a bug
of libc and not python.

More info later on.

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

Comment By: Martin v. Löwis (loewis)
Date: 2007-02-13 13:04

Message:
Logged In: YES 
user_id=21627
Originator: NO

Also, don't change the priority of bugs.

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

Comment By: Martin v. Löwis (loewis)
Date: 2007-02-13 13:04

Message:
Logged In: YES 
user_id=21627
Originator: NO

Please take a look at the implementation of mktime, and reformulate it as
a C program. This should demonstrate you that the bug is not in Python, but
in the C library.

Also please respond to the question what timezone you are in.

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

Comment By: Sérgio Monteiro Basto (sergiomb)
Date: 2007-02-13 12:28

Message:
Logged In: YES 
user_id=4882
Originator: YES

Very strange !
>>> import time
>>> time.mktime((1976,9,26,0,0,0,0,0,0))
212544000.0
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
90000.0
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
86400.0
>>> time.mktime((1976,9,26,0,0,0,0,0,0))
212540400.0


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

Comment By: Sérgio Monteiro Basto (sergiomb)
Date: 2007-02-13 12:19

Message:
Logged In: YES 
user_id=4882
Originator: YES

on my FC6 same 
first time 
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
90000.0
second and third time 
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
86400.0
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
86400.0

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

Comment By: Sérgio Monteiro Basto (sergiomb)
Date: 2007-02-13 12:18

Message:
Logged In: YES 
user_id=4882
Originator: YES

here with ubuntu 5.16 with python 2.4.2
kernel-2.6.12
>>> import time
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
90000.0
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
86400.0
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
86400.0

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

Comment By: Sérgio Monteiro Basto (sergiomb)
Date: 2007-02-13 12:06

Message:
Logged In: YES 
user_id=4882
Originator: YES

here with ubuntu 6.10 with python 2.4.4c1 
>>> import time
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
90000.0

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

Comment By: Martin v. Löwis (loewis)
Date: 2007-02-13 06:57

Message:
Logged In: YES 
user_id=21627
Originator: NO

Looks like an FC6 bug to me (either in their C library, or in their Python
port). On Debian 3.1, Python 2.4.1, I also get 86400.0. Please report this
to Redhat; I'm closing this as "works for me". If you stil think there is a
bug in Python, please point to the exact source that you think is
erroneous, and the change that should be made.

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

Comment By: Sérgio Monteiro Basto (sergiomb)
Date: 2007-02-12 23:37

Message:
Logged In: YES 
user_id=4882
Originator: YES

python-2.4.4-1.fc6
>>> import time
>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
90000.0


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

Comment By: Martin v. Löwis (loewis)
Date: 2007-02-12 13:38

Message:
Logged In: YES 
user_id=21627
Originator: NO

I can't reproduce this problem. On my system (OSX), I get

>>>
time.mktime((1976,9,26,0,0,0,0,0,0))-time.mktime((1976,9,25,0,0,0,0,0,0))
86400.0

What system are you using? What Python version? What timezone are you in?

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

Comment By: Georg Brandl (gbrandl)
Date: 2007-02-10 16:06

Message:
Logged In: YES 
user_id=849994
Originator: NO

This appears to be a timezone/DST issue:
on Sept. 26, 1976 Daylight Saving Time ended at least in the European
Union.

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

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


More information about the Python-bugs-list mailing list