import calendar


def get_weekday(day):
    """
    get the weekday of a date, e.g. 04 May 2017 is the 1st Thursday of the
    month, so get_weekday(date(2017, 5, 4)) == (3, 1)
    :param day: a datetime.date object
    :return: a tuple of the week day of the day and the position in the month
    """
    month_cal = calendar.monthcalendar(day.year, day.month)
    if month_cal[0][0] != 0:
        offset = day.day - month_cal[0][0]
        return offset % 7, offset // 7 + 1
    else:
        offset = day.day - month_cal[1][0]
        return offset % 7, offset // 7 + 1