Return :class:`datetime.datetime` object from given string,
    or ``None`` if failed to translate.

def string2time(text):
    """Return :class:`datetime.datetime` object from given string,
    or ``None`` if failed to translate."""
    length = len(TIME_FORMAT)
    result = None
    while length:
        try:
            result = datetime.strptime(text, TIME_FORMAT[:length])
        except:
            length -= 1
        else:
            break
    return result