(dtstr)
| 356 | |
| 357 | |
| 358 | def _parse_isoformat_date(dtstr): |
| 359 | # It is assumed that this is an ASCII-only string of lengths 7, 8 or 10, |
| 360 | # see the comment on Modules/_datetimemodule.c:_find_isoformat_datetime_separator |
| 361 | assert len(dtstr) in (7, 8, 10) |
| 362 | year = int(dtstr[0:4]) |
| 363 | has_sep = dtstr[4] == '-' |
| 364 | |
| 365 | pos = 4 + has_sep |
| 366 | if dtstr[pos:pos + 1] == "W": |
| 367 | # YYYY-?Www-?D? |
| 368 | pos += 1 |
| 369 | weekno = int(dtstr[pos:pos + 2]) |
| 370 | pos += 2 |
| 371 | |
| 372 | dayno = 1 |
| 373 | if len(dtstr) > pos: |
| 374 | if (dtstr[pos:pos + 1] == '-') != has_sep: |
| 375 | raise ValueError("Inconsistent use of dash separator") |
| 376 | |
| 377 | pos += has_sep |
| 378 | |
| 379 | dayno = int(dtstr[pos:pos + 1]) |
| 380 | |
| 381 | return list(_isoweek_to_gregorian(year, weekno, dayno)) |
| 382 | else: |
| 383 | month = int(dtstr[pos:pos + 2]) |
| 384 | pos += 2 |
| 385 | if (dtstr[pos:pos + 1] == "-") != has_sep: |
| 386 | raise ValueError("Inconsistent use of dash separator") |
| 387 | |
| 388 | pos += has_sep |
| 389 | day = int(dtstr[pos:pos + 2]) |
| 390 | |
| 391 | return [year, month, day] |
| 392 | |
| 393 | |
| 394 | _FRACTION_CORRECTION = [100000, 10000, 1000, 100, 10] |
no test coverage detected
searching dependent graphs…