Returns a copy of the instance with the time reset with the following rules: * week: date to last day of the week * month: date to last day of the month * year: date to last day of the year * decade: date to last day of the decade * century:
(self, unit: str)
| 350 | return cast("Self", getattr(self, f"_start_of_{unit}")()) |
| 351 | |
| 352 | def end_of(self, unit: str) -> Self: |
| 353 | """ |
| 354 | Returns a copy of the instance with the time reset |
| 355 | with the following rules: |
| 356 | |
| 357 | * week: date to last day of the week |
| 358 | * month: date to last day of the month |
| 359 | * year: date to last day of the year |
| 360 | * decade: date to last day of the decade |
| 361 | * century: date to last day of century |
| 362 | |
| 363 | :param unit: The unit to reset to |
| 364 | """ |
| 365 | if unit not in self._MODIFIERS_VALID_UNITS: |
| 366 | raise ValueError(f'Invalid unit "{unit}" for end_of()') |
| 367 | |
| 368 | return cast("Self", getattr(self, f"_end_of_{unit}")()) |
| 369 | |
| 370 | def _start_of_day(self) -> Self: |
| 371 | """ |
no outgoing calls