def weekend_type_init(M, i, t):
    """
    Determines type of weekend using midnight threshold parameters

    :param M: Model
    :param i: period
    :param t: tour type
    :return: 1 if Sat and Sun, 2 if Fri and Sat
    """

    result = 1
    lens = [M.lengths[k] for k in M.tt_length_x[t]]
    max_len = max(lens)
    if i + max_len - 1 >= M.midnight_thresh[t]:
        result = 2

    return result