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. DateTime.MONDAY.
(self, day_of_week: WeekDay | None = None, keep_time: bool = False)
| 920 | return dt.end_of("day") |
| 921 | |
| 922 | def next(self, day_of_week: WeekDay | None = None, keep_time: bool = False) -> Self: |
| 923 | """ |
| 924 | Modify to the next occurrence of a given day of the week. |
| 925 | If no day_of_week is provided, modify to the next occurrence |
| 926 | of the current day of the week. Use the supplied consts |
| 927 | to indicate the desired day_of_week, ex. DateTime.MONDAY. |
| 928 | """ |
| 929 | if day_of_week is None: |
| 930 | day_of_week = self.day_of_week |
| 931 | |
| 932 | if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY: |
| 933 | raise ValueError("Invalid day of week") |
| 934 | |
| 935 | dt = self if keep_time else self.start_of("day") |
| 936 | |
| 937 | dt = dt.add(days=1) |
| 938 | while dt.day_of_week != day_of_week: |
| 939 | dt = dt.add(days=1) |
| 940 | |
| 941 | return dt |
| 942 | |
| 943 | def previous( |
| 944 | self, day_of_week: WeekDay | None = None, keep_time: bool = False |
no test coverage detected