MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / _add_timedelta_

Method _add_timedelta_

src/pendulum/datetime.py:670–688  ·  view source on GitHub ↗

Add timedelta duration to the instance.

(self, delta: datetime.timedelta)

Source from the content-addressed store, hash-verified

668 # to avoid errors for PyPy which already defines
669 # a _add_timedelta method
670 def _add_timedelta_(self, delta: datetime.timedelta) -> Self:
671 """
672 Add timedelta duration to the instance.
673 """
674 if isinstance(delta, pendulum.Interval):
675 return self.add(
676 years=delta.years,
677 months=delta.months,
678 weeks=delta.weeks,
679 days=delta.remaining_days,
680 hours=delta.hours,
681 minutes=delta.minutes,
682 seconds=delta.remaining_seconds,
683 microseconds=delta.microseconds,
684 )
685 elif isinstance(delta, pendulum.Duration):
686 return self.add(**delta._signature) # type: ignore[attr-defined]
687
688 return self.add(seconds=delta.total_seconds())
689
690 def _subtract_timedelta(self, delta: datetime.timedelta) -> Self:
691 """

Callers 1

__add__Method · 0.95

Calls 2

addMethod · 0.95
total_secondsMethod · 0.45

Tested by

no test coverage detected