time + timedelta

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • josh@yucs.org

    #1

    time + timedelta

    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.timede lta(hours=-1)
    should no longer normalize to datetime.timede lta(-1, 82800)

Working...