Get the difference in a human readable format in the current locale. When comparing a value in the past to default now: 1 day ago 5 months ago When comparing a value in the future to default now: 1 day from now 5 months from now Whe
( # type: ignore[override]
self,
other: DateTime | None = None,
absolute: bool = False,
locale: str | None = None,
)
| 712 | return Interval(self, dt, absolute=abs) |
| 713 | |
| 714 | def diff_for_humans( # type: ignore[override] |
| 715 | self, |
| 716 | other: DateTime | None = None, |
| 717 | absolute: bool = False, |
| 718 | locale: str | None = None, |
| 719 | ) -> str: |
| 720 | """ |
| 721 | Get the difference in a human readable format in the current locale. |
| 722 | |
| 723 | When comparing a value in the past to default now: |
| 724 | 1 day ago |
| 725 | 5 months ago |
| 726 | |
| 727 | When comparing a value in the future to default now: |
| 728 | 1 day from now |
| 729 | 5 months from now |
| 730 | |
| 731 | When comparing a value in the past to another value: |
| 732 | 1 day before |
| 733 | 5 months before |
| 734 | |
| 735 | When comparing a value in the future to another value: |
| 736 | 1 day after |
| 737 | 5 months after |
| 738 | """ |
| 739 | is_now = other is None |
| 740 | |
| 741 | if is_now: |
| 742 | other = self.now() |
| 743 | |
| 744 | diff = self.diff(other) |
| 745 | |
| 746 | return pendulum.format_diff(diff, is_now, absolute, locale) |
| 747 | |
| 748 | # Modifiers |
| 749 | def start_of(self, unit: str) -> Self: |