time.mktime problem

Edvard Majakari edvard+news at majakari.net
Tue Aug 30 07:48:24 EDT 2005


"McBooCzech" <petr at tpc.cz> writes:

> Hi, on Linux (Fedora FC4) and Python 2.4.1
> I am trying to know the time delta in seconds between two times given
> in the HHMMSS format. My code looks like:
>
> import datetime, time
> ta1=(time.strptime('000001', '%H%M%S'))
> ta2=(time.strptime('230344', '%H%M%S'))
> t1=time.mktime(ta1)
> t2=time.mktime(ta2)
> print t1, t2
>
> -2147483648.0 -2147483648.0
>
> I just can not figure out, why the t1 and t2 are the same?

Hm. You are trying to convert (1900, 1, 1, 0, 0, 1, 0, 1, -1) to epoch. 
However, epochs start from 1970-01-01 00:00. So that at least is not right.

Hint... see what var ta1 is. With python2.3 you'll get overflow error, becuase
mktime argument is out of range.

-- 
# Edvard Majakari		Software Engineer
# PGP PUBLIC KEY available    	Soli Deo Gloria!

$_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n";



More information about the Python-list mailing list