[Tutor] Question on Time calculations.
montana
montana@buc99.bsd.st
Wed Jan 15 16:12:02 2003
This what I've got so far. I'm no math wiz, so please email me any math corrections or any improvements you see:
#!/usr/bin/env python
from time import strptime, mktime
stime = raw_input("Enter Start Date and Time: ")
etime = raw_input("Enter End Date and Time: ")
a = mktime(strptime(stime, "%m.%d.%y %H%M"))
b = mktime(strptime(etime, "%m.%d.%y %H%M"))
hours = int((b-a)/(60*60))
min = int(((b-a)%(60*60)/60))
print "The total time is: %d hrs, %d min" % (hours, min)
Thanks.
SA
:)