def parse_datetime(src=None):
if src is None:<EOL><INDENT>return None<EOL><DEDENT>string = src.replace('<STR_LIT:">', "<STR_LIT>")<EOL>m = UTC_OFFSET_RE.match(string)<EOL>if m:<EOL><INDENT>sign = <NUM_LIT:1> if m.group("<STR_LIT>") == "<STR_LIT:+>" else -<NUM_LIT:1><EOL>tz_hours = sign * int(m.group("<STR_LIT>"))<EOL>tz_minutes = sign * int(m.group("<STR_LIT>"))<EOL>offset = datetime.timedelta(hours=tz_hours, minutes=tz_minutes)<EOL>string = string[:-<NUM_LIT:6>]<EOL><DEDENT>else:<EOL><INDENT>offset = datetime.timedelta(<NUM_LIT:0>)<EOL><DEDENT>if "<STR_LIT>" in string or "<STR_LIT>" in string:<EOL><INDENT>datetime_obj = datetime.datetime.strptime(string, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>datetime_obj = datetime.datetime.strptime(string, "<STR_LIT>")<EOL><DEDENT>return datetime_obj + offset<EOL>
Parse a datetime object from a string.