time + timedelta

J

josh

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top