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

Method last_of

src/pendulum/datetime.py:981–994  ·  view source on GitHub ↗

Returns an instance set to the last occurrence of a given day of the week in the current unit. If no day_of_week is provided, modify to the last day of the unit. Use the supplied consts to indicate the desired day_of_week, ex. DateTime.MONDAY. Suppor

(self, unit: str, day_of_week: WeekDay | None = None)

Source from the content-addressed store, hash-verified

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 """
983 Returns an instance set to the last occurrence
984 of a given day of the week in the current unit.
985 If no day_of_week is provided, modify to the last day of the unit.
986 Use the supplied consts to indicate the desired day_of_week,
987 ex. DateTime.MONDAY.
988
989 Supported units are month, quarter and year.
990 """
991 if unit not in ["month", "quarter", "year"]:
992 raise ValueError(f'Invalid unit "{unit}" for first_of()')
993
994 return cast("Self", getattr(self, f"_last_of_{unit}")(day_of_week))
995
996 def nth_of(self, unit: str, nth: int, day_of_week: WeekDay) -> Self:
997 """

Callers 2

_last_of_quarterMethod · 0.45
_last_of_yearMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected