Returns a copy of the instance with the time reset with the following rules: * second: microsecond set to 0 * minute: second and microsecond set to 0 * hour: minute, second and microsecond set to 0 * day: time to 00:00:00 * week: date to firs
(self, unit: str)
| 747 | |
| 748 | # Modifiers |
| 749 | def start_of(self, unit: str) -> Self: |
| 750 | """ |
| 751 | Returns a copy of the instance with the time reset |
| 752 | with the following rules: |
| 753 | |
| 754 | * second: microsecond set to 0 |
| 755 | * minute: second and microsecond set to 0 |
| 756 | * hour: minute, second and microsecond set to 0 |
| 757 | * day: time to 00:00:00 |
| 758 | * week: date to first day of the week and time to 00:00:00 |
| 759 | * month: date to first day of the month and time to 00:00:00 |
| 760 | * year: date to first day of the year and time to 00:00:00 |
| 761 | * decade: date to first day of the decade and time to 00:00:00 |
| 762 | * century: date to first day of century and time to 00:00:00 |
| 763 | """ |
| 764 | if unit not in self._MODIFIERS_VALID_UNITS: |
| 765 | raise ValueError(f'Invalid unit "{unit}" for start_of()') |
| 766 | |
| 767 | return cast("Self", getattr(self, f"_start_of_{unit}")()) |
| 768 | |
| 769 | def end_of(self, unit: str) -> Self: |
| 770 | """ |
no outgoing calls
no test coverage detected