[Tutor] time question
Kalle Svensson
kalle@gnupung.net
Thu, 23 Aug 2001 17:40:19 +0200
[Rob Andrews]
> But fortunately I have a nice, specific question. After user input, I
> have the quit time stored thusly:
[time juggling]
> Does anyone know a way to do this more directly, elegantly, or briefly?
You could use time.localtime() to get a tuple and then compare the tuples.
Extremely crude example:
>>> import time
>>> quitTime = (2001, 8, 22, 9, 45, -1, -1, -1, -1)
>>> for field, index in zip(["years", "months", "days", "hours", "minutes"],
... range(5)):
... print field, time.localtime(time.time())[index] - quitTime[index]
...
years 0
months 0
days 1
hours 8
minutes -13
>>>
Don't know if it's better...
Peace,
Kalle
--
[ kalle@gnupung.net ][ Thought control, brought to you by the WIPO! ]
[ http://gnupung.net/ ][ http://anti-dmca.org/ http://eurorights.org/ ]