def parse_iso_datetime(value):
    #NEEDS-TEST
    match = ISO_DATETIME_RE.match(value)
    if not match:
        raise InvalidFormat('invalid ISO-8601 date/time: "{}"'.format(value))

    # split out into datetime, secs, usecs, and tz
    dtstr = match.group(1)
    secs = match.group(3)
    usecs = match.group(4)
    tzstr = match.group(5)

    # replace the "T" if given
    dtstr = dtstr.replace('T', ' ')
    try:
        dt_args = time.strptime(dtstr, '%Y-%m-%d %H:%M')[:5]
    except __HOLE__:
        raise InvalidDate('invalid date: "{}"'.format(value))

    # append seconds, usecs, and tz
    dt_args += (int(secs) if secs else 0,)
    dt_args += (int(usecs.lstrip('.')) if usecs else 0,)
    dt_args += (parse_tz(tzstr),)

    try:
        return datetime(*dt_args)
    except ValueError:
        raise InvalidDate('invalid date: "{}"'.format(value))
dataset/ETHPy150Open bendavis78/python-gitmodel/gitmodel/utils/isodate.py/parse_iso_datetime