def _get_contiguous_times(times, tolerance=2):
    """
    Returns tuples of start and end times inferred from list of all times.

    For example, [1, 2, 3, 5, 6, 7, 10] would yield ((1, 3), (5, 7), (10, 10))
    :param times: a list or series of ints. Must be sorted ascending.
    :param tolerance: gaps must be at least this long to be registered. E.g. 2 skips 1-sec shift anomalies

    :return: tuple of tuple-2s of ints
    """
    cont_times = []
    for i in range(len(times)):
        if i == 0:
            cont_times.append([times[i], times[i]])
        else:
            if times[i] == times[i - 1] + 1:
                cont_times[-1][-1] = times[i]
            else:
                cont_times.append([times[i], times[i]])
    cont_times = tuple((s, e) for s, e in cont_times if e - s >= tolerance)
    return cont_times