(dtstr)
| 323 | |
| 324 | |
| 325 | def _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] |
no test coverage detected