def set_prev_iso_week_day(val, iso_week_day):
    """
    Set ISO week day.
    New date will be less or equal than input date.
    :param val: datetime or date
    :type val: datetime.datetime | datetime.date
    :param iso_week_day: ISO week day to set
    :type iso_week_day: int
    :return: datetime.datetime | datetime.date
    """
if val.isoweekday() == iso_week_day:
    return val
diff = iso_week_day - val.isoweekday()
diff = -diff if diff < 0 else 7 - diff
val -= timedelta(days=diff)
return val
datenow = set_prev_iso_week_day(datenow, 5).replace(hour=16, minute=0,
    second=0, microsecond=0)
How to create dates using datetime based on day of the week?