MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __add__

Method __add__

tools/python-3.11.9-amd64/Lib/datetime.py:2177–2194  ·  view source on GitHub ↗

Add a datetime and a timedelta.

(self, other)

Source from the content-addressed store, hash-verified

2175 return diff and 1 or 0
2176
2177 def __add__(self, other):
2178 "Add a datetime and a timedelta."
2179 if not isinstance(other, timedelta):
2180 return NotImplemented
2181 delta = timedelta(self.toordinal(),
2182 hours=self._hour,
2183 minutes=self._minute,
2184 seconds=self._second,
2185 microseconds=self._microsecond)
2186 delta += other
2187 hour, rem = divmod(delta.seconds, 3600)
2188 minute, second = divmod(rem, 60)
2189 if 0 < delta.days <= _MAXORDINAL:
2190 return type(self).combine(date.fromordinal(delta.days),
2191 time(hour, minute, second,
2192 delta.microseconds,
2193 tzinfo=self._tzinfo))
2194 raise OverflowError("result out of range")
2195
2196 __radd__ = __add__
2197

Callers

nothing calls this directly

Calls 6

timedeltaClass · 0.85
timeClass · 0.85
toordinalMethod · 0.80
fromordinalMethod · 0.80
typeClass · 0.50
combineMethod · 0.45

Tested by

no test coverage detected