doubledate.sow#
- doubledate.sow(date: date, offset: int = 0, weekday: str = 'MON') date #
Returns the start of the week, i.e. the first date on or before 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 start of the week
offset (int, optional) – the number of weeks from which to offset the most recent start of the week (default is 0)
weekday (str, optional) – the weekday which defines the start of the week (default is
"MON"
)
- Returns:
The start of the week
- Return type:
datetime.date
Examples
>>> today = datetime.date(2020, 1, 15) #Wednesday >>> sow(today) datetime.date(2020, 1, 13) #last Monday
>>> sow(today, 1) datetime.date(2020, 1, 20) #following Monday
>>> sow(today, weekday="WED") datetime.date(2020, 1, 15) #today
>>> sow(today, weekday="THU") datetime.date(2020, 1, 9) #last Thursday