Returns an instance set to the last occurrence of a given day of the week in the current unit. If no day_of_week is provided, modify to the last day of the unit. Use the supplied consts to indicate the desired day_of_week, ex. pendulum.MONDAY. Suppor
(self, unit: str, day_of_week: WeekDay | None = None)
| 518 | return cast("Self", getattr(self, f"_first_of_{unit}")(day_of_week)) |
| 519 | |
| 520 | def last_of(self, unit: str, day_of_week: WeekDay | None = None) -> Self: |
| 521 | """ |
| 522 | Returns an instance set to the last occurrence |
| 523 | of a given day of the week in the current unit. |
| 524 | If no day_of_week is provided, modify to the last day of the unit. |
| 525 | Use the supplied consts to indicate the desired day_of_week, |
| 526 | ex. pendulum.MONDAY. |
| 527 | |
| 528 | Supported units are month, quarter and year. |
| 529 | |
| 530 | :param unit: The unit to use |
| 531 | :param day_of_week: The day of week to reset to. |
| 532 | """ |
| 533 | if unit not in ["month", "quarter", "year"]: |
| 534 | raise ValueError(f'Invalid unit "{unit}" for first_of()') |
| 535 | |
| 536 | return cast("Self", getattr(self, f"_last_of_{unit}")(day_of_week)) |
| 537 | |
| 538 | def nth_of(self, unit: str, nth: int, day_of_week: WeekDay) -> Self: |
| 539 | """ |
no outgoing calls