doubledate.last#

doubledate.last(weekday: str, *, asof=None) date#

Returns the most recent date strictly before today (or the asof date) for which the weekday is equal to the passed weekday argument.

Parameters:
  • weekday (str) – the target weekday

  • asof (datetime.date, optional) – the date from which to determine the last date (default is today)

Returns:

The first weekday strictly before the asof date

Return type:

datetime.date

Example

>>> last("MON") #assume today is Wed 15 Jan 2020
datetime.date(2020, 1, 13)
>>> last("SUN")
datetime.date(2020, 1, 12)
>>> last("WED", asof=datetime.date(2020, 1, 15))
datetime.date(2020, 1, 8)