[Tutor] Question on Time calculations.

montana montana@buc99.bsd.st
Fri Jan 17 15:39:29 2003


Got it. Thanks.

That what I thought I goofed on.  I now have the following:

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

start = raw_input("Enter Start Date and Time: ")
end = raw_input("Enter End Date and Time: ")

def enterTime(dt):
	date, time = dt.split()
	month, day, year = map(int,date.split('.'))
	hour, min = map(int,[time[:-2], time[-2:]])
	outtime = DateTime.DateTime(year, month, day, hour, min, 0)
	return outtime

def timeCalc(stime, etime):
	c = etime - stime
	hours = ((c.day*24)+c.hour)
	min = c.minute
	return hours, min

stime = enterTime(start)
etime = enterTime(end)
hours, min = timeCalc(stime, etime)

print "The total time is: %d hrs, %d min" % (hours, min)


Does this look better?

Thanks for the help.
SA
:)


On Thursday, January 16, 2003, at 05:52 PM, Magnus Lycka wrote:

At 17:11 2003-01-16 -0600, montana wrote:
But then how do you get the date parsed?

There is a whole row of Date, Time and DateTime
constructors in mxDateTime.

mx.DateTime.DateTime() takes integers for year,
month and so on. The ISO and ARPA modules takes
its own formats and soforth...