MCPcopy Index your code
hub / github.com/python/cpython / _normalize_datetime_str

Function _normalize_datetime_str

Lib/test/test_tomllib/burntsushi.py:68–89  ·  view source on GitHub ↗
(dt_str: str)

Source from the content-addressed store, hash-verified

66
67
68def _normalize_datetime_str(dt_str: str) -> str:
69 if dt_str[-1].lower() == "z":
70 dt_str = dt_str[:-1] + "+00:00"
71
72 date = dt_str[:10]
73 rest = dt_str[11:]
74
75 if "+" in rest:
76 sign = "+"
77 elif "-" in rest:
78 sign = "-"
79 else:
80 sign = ""
81
82 if sign:
83 time, _, offset = rest.partition(sign)
84 else:
85 time = rest
86 offset = ""
87
88 time = time.rstrip("0") if "." in time else time
89 return date + "T" + time + sign + offset
90
91
92def _normalize_localtime_str(lt_str: str) -> str:

Callers 2

convertFunction · 0.85
normalizeFunction · 0.85

Calls 3

lowerMethod · 0.45
partitionMethod · 0.45
rstripMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…