[Tutor] time question

Rob Andrews rob@jam.rr.com
Thu, 23 Aug 2001 11:59:33 -0500

Lloyd Kvam wrote:
> Is there any reason for not using MxDateTime?
> http://www.lemburg.com/files/python/mxDateTime.html
> It may be overkill for your purposes, but I would think that's generally better than the alternatives.

This does look like an interesting package, worth further
experimentation. For this application, I do want to stick with the
standard-issue library components for now, though.

I also like Kalle's idea:

>>> 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] -
years 0
months 0
days 1
hours 8
minutes -13

It seems to have the benefit of simplicity.

I'm currently playing with the idea of stepping through it with divmod()
to extract years, .. minutes. It seems roughly equivalent in human
effort to the process of preventing trouble from output such as "minutes

This is why I love programming. One can spend hours determining the
*best* way to do something that could be coded roughly in a few minutes.

A {} is a terrible thing to waste.
Useless Python!