MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / start_of

Method start_of

src/pendulum/date.py:333–350  ·  view source on GitHub ↗

Returns a copy of the instance with the time reset with the following rules: * day: time to 00:00:00 * week: date to first day of the week and time to 00:00:00 * month: date to first day of the month and time to 00:00:00 * year: date to first day of

(self, unit: str)

Source from the content-addressed store, hash-verified

331 # MODIFIERS
332
333 def start_of(self, unit: str) -> Self:
334 """
335 Returns a copy of the instance with the time reset
336 with the following rules:
337
338 * day: time to 00:00:00
339 * week: date to first day of the week and time to 00:00:00
340 * month: date to first day of the month and time to 00:00:00
341 * year: date to first day of the year and time to 00:00:00
342 * decade: date to first day of the decade and time to 00:00:00
343 * century: date to first day of century and time to 00:00:00
344
345 :param unit: The unit to reset to
346 """
347 if unit not in self._MODIFIERS_VALID_UNITS:
348 raise ValueError(f'Invalid unit "{unit}" for start_of()')
349
350 return cast("Self", getattr(self, f"_start_of_{unit}")())
351
352 def end_of(self, unit: str) -> Self:
353 """

Calls

no outgoing calls