Modify to the next occurrence of a given day of the week. If no day_of_week is provided, modify to the next occurrence of the current day of the week. Use the supplied consts to indicate the desired day_of_week, ex. pendulum.MONDAY. :param day_of_week: The
(self, day_of_week: WeekDay | None = None)
| 458 | return dt.end_of("day") |
| 459 | |
| 460 | def next(self, day_of_week: WeekDay | None = None) -> Self: |
| 461 | """ |
| 462 | Modify to the next occurrence of a given day of the week. |
| 463 | If no day_of_week is provided, modify to the next occurrence |
| 464 | of the current day of the week. Use the supplied consts |
| 465 | to indicate the desired day_of_week, ex. pendulum.MONDAY. |
| 466 | |
| 467 | :param day_of_week: The next day of week to reset to. |
| 468 | """ |
| 469 | if day_of_week is None: |
| 470 | day_of_week = self.day_of_week |
| 471 | |
| 472 | if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY: |
| 473 | raise ValueError("Invalid day of week") |
| 474 | |
| 475 | dt = self.add(days=1) |
| 476 | while dt.day_of_week != day_of_week: |
| 477 | dt = dt.add(days=1) |
| 478 | |
| 479 | return dt |
| 480 | |
| 481 | def previous(self, day_of_week: WeekDay | None = None) -> Self: |
| 482 | """ |