Bug (??) in the time module?
Anoop Aryal
aryal at ameritech.net
Tue Jun 17 17:05:29 EDT 2003
Paul Watson wrote:
> I get the same result using Python 2.2.2 on Linux. However, I get a
> different result using 2.3.b1 on Windows 2000. If you are going to persist
> a timestamp, it might be a good idea to write it in UTC. Using ISO 8601
> format might be a good idea as well.
>
> C:\src\python\t>cat tim.py
> #! /usr/bin/python
>
> import time
>
> thetime = time.time()
> timeString = time.ctime(thetime)
> print timeString
> timeTuple = time.strptime(timeString)
> print timeTuple
> thetime2 = time.mktime(timeTuple)
> timeString2 = time.ctime(thetime2)
> print timeString2
>
> C:\src\python\t>tim.py
> Tue Jun 17 09:48:01 2003
> (2003, 6, 17, 9, 48, 1, 1, 168, -1)
> Tue Jun 17 09:48:01 2003
>
>
your time tuple is different from mine (of course. but i'm talking about
the last number in the list). it would be interesting to see if you got
the same number on linux and windows at the last position in the tuple
(here it's -1)
but regardless of the time format, round tripping using the defaults
should have been handled correctly, right?
i have to use localtime since this is a 'report' of when certain things
ran and i don't want to figure out the conversion to/from UTC everytime
i see the report. but it also doubles as a makefile type dependency
tracking. so i need the round tripping. i ended up comparing the tuple
and is working for the most part.
thanks for your input tho.
anoop.
More information about the Python-list
mailing list