def _convert_timestr_to_seconds(time_str, rec_start):
    """Convert input from user about time string to an absolute time for
    the recordings.

    Parameters
    ----------
    time_str : str
        time information as '123' or '22:30' or '22:30:22'
    rec_start: instance of datetime
        absolute start time of the recordings.

    Returns
    -------
    int
        start time of the window, in s, from the start of the recordings

    Raises
    ------
    ValueError
        if it cannot convert the string
    """
    if not CHECK_TIME_STR.match(time_str):
        raise ValueError('Input can only contain digits and colons')

    if ':' in time_str:
        time_split = [int(x) for x in time_str.split(':')]

        # if it's in 'HH:MM' format, add ':SS'
        if len(time_split) == 2:
            time_split.append(0)
        clock_time = time(*time_split)

        chosen_start = datetime.combine(rec_start.date(), clock_time)
        # if the clock time is after start of the recordings, assume it's the next day
        if clock_time < rec_start.time():
            chosen_start += timedelta(days=1)

        window_start = int((chosen_start - rec_start).total_seconds())
    else:
        window_start = int(time_str)

    return window_start
def _convert_timestr_to_seconds ( time_str , rec_start ) : if not CHECK_TIME_STR . match ( time_str ) : raise ValueError ( 'Input can only contain digits and colons' ) if ':' in time_str : time_split = [ int ( x ) for x in time_str . split ( ':' ) ] if len ( time_split ) == 2 : time_split . append ( 0 ) clock_time = time ( * time_split ) chosen_start = datetime . combine ( rec_start . date ( ) , clock_time ) if clock_time < rec_start . time ( ) : chosen_start += timedelta ( days = 1 ) window_start = int ( ( chosen_start - rec_start ) . total_seconds ( ) ) else : window_start = int ( time_str ) return window_start
Convert input from user about time string to an absolute time for
    the recordings.

    Parameters
    ----------
    time_str : str
        time information as '123' or '22:30' or '22:30:22'
    rec_start: instance of datetime
        absolute start time of the recordings.

    Returns
    -------
    int
        start time of the window, in s, from the start of the recordings

    Raises
    ------
    ValueError
        if it cannot convert the string