def parse_datetime(value):
match = datetime_re.match(value)<EOL>if match:<EOL><INDENT>kw = match.groupdict()<EOL>if kw['<STR_LIT>']:<EOL><INDENT>kw['<STR_LIT>'] = kw['<STR_LIT>'].ljust(<NUM_LIT:6>, '<STR_LIT:0>')<EOL><DEDENT>tzinfo = kw.pop('<STR_LIT>')<EOL>if tzinfo == '<STR_LIT>':<EOL><INDENT>tzinfo = utc<EOL><DEDENT>elif tzinfo is not None:<EOL><INDENT>offset_mins = int(tzinfo[-<NUM_LIT:2>:]) if len(tzinfo) > <NUM_LIT:3> else <NUM_LIT:0><EOL>offset = <NUM_LIT> * int(tzinfo[<NUM_LIT:1>:<NUM_LIT:3>]) + offset_mins<EOL>if tzinfo[<NUM_LIT:0>] == '<STR_LIT:->':<EOL><INDENT>offset = -offset<EOL><DEDENT>tzinfo = get_fixed_timezone(offset)<EOL><DEDENT>kw = {k: int(v) for k, v in kw.items() if v is not None}<EOL>kw['<STR_LIT>'] = tzinfo<EOL>return datetime.datetime(**kw)<EOL><DEDENT>
Parses a string and return a datetime.datetime.

    This function supports time zone offsets. When the input contains one,
    the output uses a timezone with a fixed offset from UTC.

    Raises ValueError if the input is well formatted but not a valid datetime.
    Returns None if the input isn't well formatted.