Add timedelta duration to the instance.
(self, delta: datetime.timedelta)
| 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 | """ |
no test coverage detected