Bugs item #1656559, was opened at 2007-02-10 03:41 Message generated for change (Settings changed) made by gbrandl 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: None >Status: Pending Resolution: None 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: Sérgio Monteiro Basto (sergiomb) Date: 2007-02-13 14: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 12: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 12: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 12: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 12: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 12: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 11: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 11: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 11: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 11: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 05: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 22: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 12: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 15: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 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com