def parse_rfc3339_utc_string(rfc3339_utc_string):
<EOL>m = re.match(r'<STR_LIT>',<EOL>rfc3339_utc_string)<EOL>if not m:<EOL><INDENT>return None<EOL><DEDENT>groups = m.groups()<EOL>if len(groups[<NUM_LIT:6>]) not in (<NUM_LIT:0>, <NUM_LIT:3>, <NUM_LIT:6>, <NUM_LIT:9>):<EOL><INDENT>return None<EOL><DEDENT>g = [int(val) for val in groups[:<NUM_LIT:6>]]<EOL>fraction = groups[<NUM_LIT:6>]<EOL>if not fraction:<EOL><INDENT>micros = <NUM_LIT:0><EOL><DEDENT>elif len(fraction) == <NUM_LIT:3>:<EOL><INDENT>micros = int(fraction) * <NUM_LIT:1000><EOL><DEDENT>elif len(fraction) == <NUM_LIT:6>:<EOL><INDENT>micros = int(fraction)<EOL><DEDENT>elif len(fraction) == <NUM_LIT:9>:<EOL><INDENT>micros = int(round(int(fraction) / <NUM_LIT:1000>))<EOL><DEDENT>else:<EOL><INDENT>assert False, '<STR_LIT>'.len(fraction)<EOL><DEDENT>try:<EOL><INDENT>return datetime(g[<NUM_LIT:0>], g[<NUM_LIT:1>], g[<NUM_LIT:2>], g[<NUM_LIT:3>], g[<NUM_LIT:4>], g[<NUM_LIT:5>], micros, tzinfo=pytz.utc)<EOL><DEDENT>except ValueError as e:<EOL><INDENT>assert False, '<STR_LIT>'.format(<EOL>rfc3339_utc_string, e)<EOL><DEDENT>
Converts a datestamp from RFC3339 UTC to a datetime.

    Args:
      rfc3339_utc_string: a datetime string in RFC3339 UTC "Zulu" format

    Returns:
      A datetime.