doubledate.eow#
- doubledate.eow(date: date, offset: int = 0, weekday: str = 'SUN') date #
Returns the end of the week, i.e. the first date on or after the given date whose weekday is equal to the the
weekday
argument, and offset by a given number of weeks.Weekday must be one of
'MON'
,'TUE'
,'WED'
,'THU'
,'FRI'
,'SAT'
or'SUN'
.- Parameters:
date (datetime.date) – the date from which to determine the end of the week
offset (int, optional) – the number of weeks from which to offset the most recent end of the week (default is 0)
weekday (str, optional) – the weekday which defines the end of the week (default is
"SUN"
)
- Returns:
The end of the week
- Return type:
datetime.date
Examples
>>> today = datetime.date(2020, 1, 15) #Wednesday >>> eow(today) datetime.date(2020, 1, 20) #Sunday (by default)
>>> eow(today, 1) datetime.date(2020, 1, 27) #following Sunday
>>> eow(today, weekday="THU") datetime.date(2020, 1, 16) #first Thursday on or after today
>>> eow(today, weekday="THU", offset=-1) datetime.date(2020, 1, 8) #most recent Thursday strictly before today