code: def weekday(when, weekday, start=mon):
      
      if isinstance(when, datetime):
          when = when.date()
  
      today = when.weekday()
      delta = weekday - today
      if weekday < start and today >= start:
          delta += 7
      elif weekday >= start and today < start:
          delta -= 7
      return when + timedelta(days=delta)
docs: Return the date for the day of this week.