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

Method next

src/pendulum/date.py:460–479  ·  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. pendulum.MONDAY. :param day_of_week: The

(self, day_of_week: WeekDay | None = None)

Source from the content-addressed store, hash-verified

458 return dt.end_of("day")
459
460 def next(self, day_of_week: WeekDay | None = None) -> Self:
461 """
462 Modify to the next occurrence of a given day of the week.
463 If no day_of_week is provided, modify to the next occurrence
464 of the current day of the week. Use the supplied consts
465 to indicate the desired day_of_week, ex. pendulum.MONDAY.
466
467 :param day_of_week: The next day of week to reset to.
468 """
469 if day_of_week is None:
470 day_of_week = self.day_of_week
471
472 if day_of_week < WeekDay.MONDAY or day_of_week > WeekDay.SUNDAY:
473 raise ValueError("Invalid day of week")
474
475 dt = self.add(days=1)
476 while dt.day_of_week != day_of_week:
477 dt = dt.add(days=1)
478
479 return dt
480
481 def previous(self, day_of_week: WeekDay | None = None) -> Self:
482 """

Callers 14

_end_of_weekMethod · 0.95
_nth_of_monthMethod · 0.45
_nth_of_quarterMethod · 0.45
_nth_of_yearMethod · 0.45
_check_parsedMethod · 0.45
test_nextFunction · 0.45
test_next_mondayFunction · 0.45
test_next_saturdayFunction · 0.45
test_next_keep_timeFunction · 0.45
test_next_invalidFunction · 0.45
test_nextFunction · 0.45
test_next_mondayFunction · 0.45

Calls 1

addMethod · 0.95

Tested by 9

test_nextFunction · 0.36
test_next_mondayFunction · 0.36
test_next_saturdayFunction · 0.36
test_next_keep_timeFunction · 0.36
test_next_invalidFunction · 0.36
test_nextFunction · 0.36
test_next_mondayFunction · 0.36
test_next_saturdayFunction · 0.36
test_next_invalidFunction · 0.36