Returns an instance set to the first occurrence of a given day of the week in the current unit. If no day_of_week is provided, modify to the first day of the unit. Use the supplied consts to indicate the desired day_of_week, ex. DateTime.MONDAY. Supp
(self, unit: str, day_of_week: WeekDay | None = None)
| 964 | return dt |
| 965 | |
| 966 | def first_of(self, unit: str, day_of_week: WeekDay | None = None) -> Self: |
| 967 | """ |
| 968 | Returns an instance set to the first occurrence |
| 969 | of a given day of the week in the current unit. |
| 970 | If no day_of_week is provided, modify to the first day of the unit. |
| 971 | Use the supplied consts to indicate the desired day_of_week, |
| 972 | ex. DateTime.MONDAY. |
| 973 | |
| 974 | Supported units are month, quarter and year. |
| 975 | """ |
| 976 | if unit not in ["month", "quarter", "year"]: |
| 977 | raise ValueError(f'Invalid unit "{unit}" for first_of()') |
| 978 | |
| 979 | return cast("Self", getattr(self, f"_first_of_{unit}")(day_of_week)) |
| 980 | |
| 981 | def last_of(self, unit: str, day_of_week: WeekDay | None = None) -> Self: |
| 982 | """ |
no outgoing calls
no test coverage detected