time + timedelta

josh at yucs.org josh at yucs.org
Mon Feb 7 11:24:20 EST 2005


datetime.time should support timedelta arithmetic, patch attached.

Times greater than 24 hours should not raise an exception, but always
wrap around. Any other behavior is too surprising. (People expect to be
able to call you up at 11pm, and say "meet me in two hours" (if you're a
night person)).

Clock time is cyclical. Though it's convenient to assign hours numbers,
an unqualified hour 23.5 is not naturally "greater than" hour 0.5.
(Though I'm not suggesting that we break this.)

The special meaning for hour 0 is only relevant for datetimes. When
dates are not involved, it shouldn't get any special treatment.
When dates are involved, it's easy to "assert datetime1.date() ==
datetime2.date()"

If this change is made however, maybe datetime.timedelta(hours=-1)
should no longer normalize to datetime.timedelta(-1, 82800)




More information about the Python-list mailing list