(self, yearfirst, dayfirst)
| 466 | return (out.get('y'), out.get('m'), out.get('d')) |
| 467 | |
| 468 | def resolve_ymd(self, yearfirst, dayfirst): |
| 469 | len_ymd = len(self) |
| 470 | year, month, day = (None, None, None) |
| 471 | |
| 472 | strids = (('y', self.ystridx), |
| 473 | ('m', self.mstridx), |
| 474 | ('d', self.dstridx)) |
| 475 | |
| 476 | strids = {key: val for key, val in strids if val is not None} |
| 477 | if (len(self) == len(strids) > 0 or |
| 478 | (len(self) == 3 and len(strids) == 2)): |
| 479 | return self._resolve_from_stridxs(strids) |
| 480 | |
| 481 | mstridx = self.mstridx |
| 482 | |
| 483 | if len_ymd > 3: |
| 484 | raise ValueError("More than three YMD values") |
| 485 | elif len_ymd == 1 or (mstridx is not None and len_ymd == 2): |
| 486 | # One member, or two members with a month string |
| 487 | if mstridx is not None: |
| 488 | month = self[mstridx] |
| 489 | # since mstridx is 0 or 1, self[mstridx-1] always |
| 490 | # looks up the other element |
| 491 | other = self[mstridx - 1] |
| 492 | else: |
| 493 | other = self[0] |
| 494 | |
| 495 | if len_ymd > 1 or mstridx is None: |
| 496 | if other > 31: |
| 497 | year = other |
| 498 | else: |
| 499 | day = other |
| 500 | |
| 501 | elif len_ymd == 2: |
| 502 | # Two members with numbers |
| 503 | if self[0] > 31: |
| 504 | # 99-01 |
| 505 | year, month = self |
| 506 | elif self[1] > 31: |
| 507 | # 01-99 |
| 508 | month, year = self |
| 509 | elif dayfirst and self[1] <= 12: |
| 510 | # 13-01 |
| 511 | day, month = self |
| 512 | else: |
| 513 | # 01-13 |
| 514 | month, day = self |
| 515 | |
| 516 | elif len_ymd == 3: |
| 517 | # Three members |
| 518 | if mstridx == 0: |
| 519 | if self[1] > 31: |
| 520 | # Apr-2003-25 |
| 521 | month, year, day = self |
| 522 | else: |
| 523 | month, day, year = self |
| 524 | elif mstridx == 1: |
| 525 | if self[0] > 31 or (yearfirst and self[2] <= 31): |
no test coverage detected