def parse_times(setting):
    """
    read out the date and times of a recording
    """
    def timestr2timeobj(time_str):
        """
        convert a time string with milliseconds to a datetime object
        """
        time, milli = time_str.split('.')
        time = datetime.datetime.strptime(time, '%H:%M:%S')
        time += datetime.timedelta(seconds=int(milli)/1000)
        return time

    tstart, tstop = [timestr2timeobj(rec[1])
                     for rec in setting.start_rec, setting.stop_rec]
    if setting.folder is None:
        folder_date_obj = None
    else:
        date_str = date_pattern.match(setting.folder).groups()[0]
        folder_date_obj = datetime.datetime.strptime(date_str,
                                                     r'%Y-%m-%d_%H-%M-%S')
        tstart = datetime.datetime.combine(folder_date_obj, tstart.time())
        tstop = datetime.datetime.combine(folder_date_obj, tstop.time())

    # by default assume that recording is stopped once every day
    if tstop < tstart:
        tstop += datetime.timedelta(days=1)

    return folder_date_obj, tstart, tstop