time-module questions

Warren Postma embed at geocities.com
Wed Apr 5 11:56:51 EDT 2000


I have a few questions on python time code (import time).

First, it appears that time.localtime returns fractions of a second in it's
values, but that time.mktime does not add this millisecond component back
in, nor does it appear to be part of the time-tuple returned by
time.localtime, and time.gmtime:

for i in range(0,10):
 x = time.time()
 tup=time.localtime(x)
 x2 = time.mktime(tup)
 print x2,' ',x
 time.sleep(0.1)

954949853.0   954949853.238
954949853.0   954949853.379
954949853.0   954949853.509
954949853.0   954949853.639
954949853.0   954949853.769
954949853.0   954949853.899
954949854.0   954949854.03
954949854.0   954949854.16
954949854.0   954949854.29
954949854.0   954949854.42

Secondly, mktime accepts localtimes only, how to I take y/m/d/h/m/s in GMT
instead of the current timezone, and convert back to a time.time() type
value (float).

What to do? Is Python 1.6 any more 'robust' in it's handling of times/dates?

Warren






More information about the Python-list mailing list