def parse_time(time):
    try:
        # just minutes
        return int(time)
    except:
        pass
    import re
    from datetime import timedelta
    # check for 00:00:00 format where
    # 00:00 is hh:mm
    # 00:00:00 is hh:mm:ss
    if ':' in time:
        s = time.split(':')
        hours = int(s[0])
        minutes = int(s[1])
        parts = {
            'hours': hours,
            'minutes': minutes,
        }
        if len(s) > 2:
            seconds = int(s[2])
            parts['seconds'] = int(s[2])
    else:
        regex = re.compile(r'((?P<days>\d+?)d)?((?P<hours>\d+?)h)'
                           '?((?P<minutes>\d+?)m)?((?P<seconds>\d+)s)?')
        parts = regex.match(time)
        if not parts:
            raise ValueError("Unable to parse time format %s" % time)
        parts = parts.groupdict()
    time_params = {}
    for (name, param) in parts.iteritems():
        if param:
            time_params[name] = int(param)
    delta = timedelta(**time_params)

    seconds = delta.seconds
    hours = seconds / 3600
    minutes = (seconds % 3600) / 60
    if (seconds % 60) > 0:
        minutes += 1
    r = (delta.days * 1440) + (60 * hours) + minutes
    return r
Parse time string and returns time in minutes.
dataset/ETHPy150Open thasso/pyjip/jip/utils.py/parse_time