Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import date, timedelta
- from dateutil.rrule import SU, WEEKLY, rrule
- def next_sunday(today: date | None = None) -> date:
- if today is None:
- today = date.today()
- if today.weekday() == SU.weekday:
- today += timedelta(days=1)
- return rrule(freq=WEEKLY, dtstart=today, byweekday=SU)[0]
Add Comment
Please, Sign In to add comment