[Datetime-SIG] Calendar vs timespan calculations...
Ethan Furman
ethan at stoneleaf.us
Fri Jul 31 00:24:38 CEST 2015
On 07/30/2015 03:10 PM, Chris Barker wrote:
> By the way -- which __add__ actually does the implementation? datetime's or timedelta's ?
class timedelta:
def __add__(self, other):
if isinstance(other, timedelta):
# for CPython compatibility, we cannot use
# our __class__ here, but need a real timedelta
return timedelta(self._days + other._days,
self._seconds + other._seconds,
self._microseconds + other._microseconds)
return NotImplemented
timedelta only adds directly to other timedeltas; so datetime is doing the actual addition.
--
~Ethan~
More information about the Datetime-SIG
mailing list