I'd like to be able to do the following:
num_intervals = (cur_date - previous_date) / interval_length
or
print (datetime.now() - (datetime.now() - timedelta(days=5)))
/ timedelta(hours=12)
# won't run, would like it to print '10'
but the division operation is unsupported on timedeltas. Is there a way that I can implement divison for timedeltas?
Edit: Looks like this was added to Python 3.2 (thanks rincewind!): http://bugs.python.org/issue2706
Division and multiplication by integers seems to work out of the box:
>>> from datetime import timedelta
>>> timedelta(hours=6)
datetime.timedelta(0, 21600)
>>> timedelta(hours=6) / 2
datetime.timedelta(0, 10800)