def within_time_period(t, time_period):
    """
    Check if time is in the time period

    Argument:
        t = given time in format (half, min, sec)
        time_period = tuple of (start_time, end_time) in format (half, min, sec)

    Return:
        boolean
    """

    start_time = time_period[0]
    end_time = time_period[1]
    assert start_time[0] == end_time[0], "TIME PERIOD NOT IN THE SAME HALF !"

    if t[0] == start_time[0]:
        t_sec = t[1]*60+t[2]
        start_sec = start_time[1]*60 + start_time[2]
        end_sec = end_time[1]*60 + end_time[2]
        if t_sec >= start_sec and t_sec <= end_sec:
            return True

    return False