[Tutor] time calc
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Fri Jun 18 14:25:12 EDT 2004
On Fri, 18 Jun 2004, kevin parks wrote:
> Anyone know if there is a module that does time math? or a method for
> doing this by hand?
Hi Kevin,
Check the 'datetime' module:
http://www.python.org/doc/lib/module-datetime.html
'datetime' defines a bunch of types, including ones for doing date and
time arithmetic. For example:
###
>>> from datetime import timedelta
>>> t1 = timedelta(hours=1)
>>> t2 = timedelta(minutes=30)
>>> t1 + t2
datetime.timedelta(0, 5400)
###
Hope this helps!
More information about the Tutor
mailing list