def parse_time(val):
    if not val:
        return None
    hr = mi = 0
    val = val.lower()
    amflag = (-1 != val.find('a'))  # set if AM is found
    pmflag = (-1 != val.find('p'))  # set if PM is found
    for noise in ":amp.":
        val = val.replace(noise, ' ')
    val = val.split()
    if len(val) > 1:
        hr = int(val[0])
        mi = int(val[1])
    else:
        val = val[0]
        if len(val) < 1:
            pass
        elif 'now' == val:
            tm = localtime()
            hr = tm[3]
            mi = tm[4]
        elif 'noon' == val:
            hr = 12
        elif len(val) < 3:
            hr = int(val)
            if not amflag and not pmflag and hr < 7:
                hr += 12
        elif len(val) < 5:
            hr = int(val[:-2])
            mi = int(val[-2:])
        else:
            hr = int(val[:1])
    if amflag and hr >= 12:
        hr = hr - 12
    if pmflag and hr < 12:
        hr = hr + 12
    return time(hr, mi)
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Paste-2.0.1/paste/util/datetimeutil.py/parse_time/original