[Zope3-dev] Dates and times

Guido van Rossum guido@python.org
Tue, 19 Nov 2002 10:48:02 -0500


> Hmmm... sorry again, I did think you were talking about
> date-time. Still, being able to say "do this in 4 hours time" would
> be cool :-)

Yes, that's what the timedelta type is for:

>>> from datetime import *
>>> t = datetime.now()
>>> print t
2002-11-19 10:46:11.836742
>>> dt = timedelta(hours=4, minutes=30)
>>> print dt
4:30:00
>>> t2 = t + dt
>>> print t2
2002-11-19 15:16:11.836742
>>> 

--Guido van Rossum (home page: http://www.python.org/~guido/)