[Tutor] time arithmetic with 2.3 datetime module
jtk at yahoo.com
Wed Feb 11 14:59:51 EST 2004
Embarrassing to ask, but I can't quite figure 'time differences' with the
2.3 datetime module. Every google link points to a copy of the docs,
no tutorials on the new functionality. Every effort I make with timedelta
or time arithmetic eventually goes awry with TypeError: unsupported type
for timedelta seconds component: datetime.time
I have a simple timecard input of strings:
date, start, end = '20040206', '10:30', '17:45'
After I parse out the date string: y,m,d = d[:4],d[4:6],d[6:]
I want to make two times from the 24h time strings, combining with the
shared parsed date if necessary, and return the difference in floating
point (e.g. 7.25). Can anyone suggest the most expedient way to do this?
More information about the Tutor