'Given a day datetime, return matching attendances'

@api.multi
def get_attendances_for_weekday(self, day_dt):

    self.ensure_one()
    weekday = day_dt.weekday()
    attendances = self.env['resource.calendar.attendance']
    for attendance in self.attendance_ids.filtered((lambda att: ((int(att.dayofweek) == weekday) and (not (att.date_from and (fields.Date.from_string(att.date_from) > day_dt.date()))) and (not (att.date_to and (fields.Date.from_string(att.date_to) < day_dt.date())))))):
        attendances |= attendance
    return attendances
