MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _parse_isoformat_date

Function _parse_isoformat_date

tools/python-3.11.9-amd64/Lib/datetime.py:325–358  ·  view source on GitHub ↗
(dtstr)

Source from the content-addressed store, hash-verified

323
324
325def _parse_isoformat_date(dtstr):
326 # It is assumed that this is an ASCII-only string of lengths 7, 8 or 10,
327 # see the comment on Modules/_datetimemodule.c:_find_isoformat_datetime_separator
328 assert len(dtstr) in (7, 8, 10)
329 year = int(dtstr[0:4])
330 has_sep = dtstr[4] == '-'
331
332 pos = 4 + has_sep
333 if dtstr[pos:pos + 1] == "W":
334 # YYYY-?Www-?D?
335 pos += 1
336 weekno = int(dtstr[pos:pos + 2])
337 pos += 2
338
339 dayno = 1
340 if len(dtstr) > pos:
341 if (dtstr[pos:pos + 1] == '-') != has_sep:
342 raise ValueError("Inconsistent use of dash separator")
343
344 pos += has_sep
345
346 dayno = int(dtstr[pos:pos + 1])
347
348 return list(_isoweek_to_gregorian(year, weekno, dayno))
349 else:
350 month = int(dtstr[pos:pos + 2])
351 pos += 2
352 if (dtstr[pos:pos + 1] == "-") != has_sep:
353 raise ValueError("Inconsistent use of dash separator")
354
355 pos += has_sep
356 day = int(dtstr[pos:pos + 2])
357
358 return [year, month, day]
359
360
361_FRACTION_CORRECTION = [100000, 10000, 1000, 100, 10]

Callers 2

fromisoformatMethod · 0.85
fromisoformatMethod · 0.85

Calls 2

listFunction · 0.85
_isoweek_to_gregorianFunction · 0.85

Tested by

no test coverage detected