@staticmethod
def _parse_time(time_str):
    'Create a timedelta or datetime object from default string reprs.'
    try:
        if ('-' in time_str):
            time_fmt = '%Y-%m-%d %H:%M:%S'
            if ('.' in time_str):
                (pre_dec, post_dec) = time_str.split('.')
                dt = datetime.strptime(pre_dec, time_fmt)
                dt.replace(microsecond=int(post_dec))
            else:
                dt = datetime.strftime(time_str, time_fmt)
            return dt
        else:
            if ('day' in time_str):
                m = re.match('(?P<days>[-\\d]+) day[s]*, (?P<hours>\\d+):(?P<minutes>\\d+):(?P<seconds>\\d[\\.\\d+]*)', time_str)
            else:
                m = re.match('(?P<hours>\\d+):(?P<minutes>\\d+):(?P<seconds>\\d[\\.\\d+]*)', time_str)
            return timedelta(**{key: float(val) for (key, val) in m.groupdict().items()})
    except Exception as e:
        logger.error(('Failed to parse "%s".' % time_str))
        raise e
Create a timedelta or datetime object from default string reprs.
@staticmethod
def _parse_time(time_str):
    
    try:
        if ('-' in time_str):
            time_fmt = '%Y-%m-%d %H:%M:%S'
            if ('.' in time_str):
                (pre_dec, post_dec) = time_str.split('.')
                dt = datetime.strptime(pre_dec, time_fmt)
                dt.replace(microsecond=int(post_dec))
            else:
                dt = datetime.strftime(time_str, time_fmt)
            return dt
        else:
            if ('day' in time_str):
                m = re.match('(?P<days>[-\\d]+) day[s]*, (?P<hours>\\d+):(?P<minutes>\\d+):(?P<seconds>\\d[\\.\\d+]*)', time_str)
            else:
                m = re.match('(?P<hours>\\d+):(?P<minutes>\\d+):(?P<seconds>\\d[\\.\\d+]*)', time_str)
            return timedelta(**{key: float(val) for (key, val) in m.groupdict().items()})
    except Exception as e:
        logger.error(('Failed to parse "%s".' % time_str))
        raise e