MCPcopy Index your code
hub / github.com/RustPython/RustPython / __add__

Method __add__

Lib/_pydatetime.py:2286–2303  ·  view source on GitHub ↗

Add a datetime and a timedelta.

(self, other)

Source from the content-addressed store, hash-verified

2284 return diff and 1 or 0
2285
2286 def __add__(self, other):
2287 "Add a datetime and a timedelta."
2288 if not isinstance(other, timedelta):
2289 return NotImplemented
2290 delta = timedelta(self.toordinal(),
2291 hours=self._hour,
2292 minutes=self._minute,
2293 seconds=self._second,
2294 microseconds=self._microsecond)
2295 delta += other
2296 hour, rem = divmod(delta.seconds, 3600)
2297 minute, second = divmod(rem, 60)
2298 if 0 < delta.days <= _MAXORDINAL:
2299 return type(self).combine(date.fromordinal(delta.days),
2300 time(hour, minute, second,
2301 delta.microseconds,
2302 tzinfo=self._tzinfo))
2303 raise OverflowError("result out of range")
2304
2305 __radd__ = __add__
2306

Callers

nothing calls this directly

Calls 7

isinstanceFunction · 0.85
timedeltaClass · 0.85
toordinalMethod · 0.80
fromordinalMethod · 0.80
timeClass · 0.70
divmodFunction · 0.50
combineMethod · 0.45

Tested by

no test coverage detected