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

Method next

src/pendulum/datetime.py:922–941  ·  view source on GitHub ↗

Modify to the next occurrence of a given day of the week. If no day_of_week is provided, modify to the next occurrence of the current day of the week. Use the supplied consts to indicate the desired day_of_week, ex. DateTime.MONDAY.

(self, day_of_week: WeekDay | None = None, keep_time: bool = False)

Source from the content-addressed store, hash-verified

920 return dt.end_of("day")
921
922 def next(self, day_of_week: WeekDay | None = None, keep_time: bool = False) -> Self:
923 """
924 Modify to the next occurrence of a given day of the week.
925 If no day_of_week is provided, modify to the next occurrence
926 of the current day of the week. Use the supplied consts
927 to indicate the desired day_of_week, ex. DateTime.MONDAY.
928 """
929 if day_of_week is None:
930 day_of_week = self.day_of_week
931
932 if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY:
933 raise ValueError("Invalid day of week")
934
935 dt = self if keep_time else self.start_of("day")
936
937 dt = dt.add(days=1)
938 while dt.day_of_week != day_of_week:
939 dt = dt.add(days=1)
940
941 return dt
942
943 def previous(
944 self, day_of_week: WeekDay | None = None, keep_time: bool = False

Callers 4

_end_of_weekMethod · 0.95
_nth_of_monthMethod · 0.45
_nth_of_quarterMethod · 0.45
_nth_of_yearMethod · 0.45

Calls 2

start_ofMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected