[Tutor] Question on Time calculations.

montana montana@buc99.bsd.st
Wed Jan 15 17:26:15 2003


Thanks for the hint Magnus.  I incorporaated the mx module and have an updated script for everyones perusal:

#!/usr/bin/env python
from time import asctime, strptime
from mx import DateTime

stime = raw_input("Enter Start Date and Time: ")
etime = raw_input("Enter End Date and Time: ")

def timeCalc(stime, etime):
	x = asctime(strptime(stime, "%m.%d.%y %H%M"))
	y = asctime(strptime(etime, "%m.%d.%y %H%M"))
	a = DateTime.Parser.DateTimeFromString(x)
	b = DateTime.Parser.DateTimeFromString(y)
	c = b - a
	return c

c = timeCalc(stime, etime)

hours = ((c.day*24)+c.hour)
min = c.minute
print "The total time is: %d hrs, %d min" % (hours, min)

Please email me your suggestions for improvement.

Thanks
SA
:)