Feature Request: Time.add() / Time.subtract() arithmetic
Problem
Every major type in whenever supports arithmetic via add() and subtract() — Date, Instant, ZonedDateTime, OffsetDateTime, PlainDateTime — but Time does not.
This makes it awkward to work with time-of-day arithmetic, which is common in scheduling scenarios (store hours, shift times, reminders, etc.).
Expected Behavior
Time(22, 0).add(hours(3)) # → Time(1, 0), wraps past midnight
Time(1, 0).subtract(hours(3)) # → Time(22, 0), wraps before midnight
Arithmetic could wrap around midnight (modular arithmetic), consistent with how most users would expect time-of-day math to work.
Current Workaround
Users currently have to manually handle the math via _to_ns_since_midnight() internals or convert to PlainDateTime first, which is verbose and leaks implementation details.
Suggested Signature
def add(self, delta: TimeDelta, /) -> Time: ...
def subtract(self, delta: TimeDelta, /) -> Time: ...
Operator overloads (__add__, __sub__) could also follow the same pattern as other types.
Notes
Python's stdlib datetime.time also skips arithmetic, so this would be a meaningful improvement over the standard library behavior.
Feature Request:
Time.add()/Time.subtract()arithmeticProblem
Every major type in
wheneversupports arithmetic viaadd()andsubtract()—Date,Instant,ZonedDateTime,OffsetDateTime,PlainDateTime— butTimedoes not.This makes it awkward to work with time-of-day arithmetic, which is common in scheduling scenarios (store hours, shift times, reminders, etc.).
Expected Behavior
Arithmetic could wrap around midnight (modular arithmetic), consistent with how most users would expect time-of-day math to work.
Current Workaround
Users currently have to manually handle the math via
_to_ns_since_midnight()internals or convert toPlainDateTimefirst, which is verbose and leaks implementation details.Suggested Signature
Operator overloads (
__add__,__sub__) could also follow the same pattern as other types.Notes
Python's stdlib
datetime.timealso skips arithmetic, so this would be a meaningful improvement over the standard library behavior.