MCPcopy Index your code
hub / github.com/pydata/xarray / _parse_iso8601

Function _parse_iso8601

xarray/coding/times.py:272–287  ·  view source on GitHub ↗
(date_type, timestr)

Source from the content-addressed store, hash-verified

270
271
272def _parse_iso8601(date_type, timestr):
273 default = date_type(1, 1, 1)
274 result = parse_iso8601_like(timestr)
275 replace = {}
276
277 for attr in ["year", "month", "day", "hour", "minute", "second", "microsecond"]:
278 value = result.get(attr, None)
279 if value is not None:
280 resolution = attr
281 if attr == "microsecond":
282 if len(value) <= 3:
283 resolution = "millisecond"
284 # convert match string into valid microsecond value
285 value = 10 ** (6 - len(value)) * int(value)
286 replace[attr] = int(value)
287 return default.replace(**replace), resolution
288
289
290def _maybe_strip_tz_from_timestamp(date: pd.Timestamp) -> pd.Timestamp:

Callers 6

test_iso8601_decodeFunction · 0.90
to_cftime_datetimeFunction · 0.90
_get_string_sliceMethod · 0.90

Calls 4

date_typeFunction · 0.85
parse_iso8601_likeFunction · 0.85
replaceMethod · 0.80
getMethod · 0.45

Tested by 2

test_iso8601_decodeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…