Parse YYYYMMDD / YYYY-MM-DD strings into date objects.
(value: str)
| 565 | |
| 566 | |
| 567 | def _parse_date(value: str) -> Optional[date]: |
| 568 | """Parse YYYYMMDD / YYYY-MM-DD strings into date objects.""" |
| 569 | normalized = (value or "").strip() |
| 570 | if not normalized: |
| 571 | return None |
| 572 | |
| 573 | for fmt in ("%Y%m%d", "%Y-%m-%d"): |
| 574 | try: |
| 575 | return datetime.strptime(normalized, fmt).date() |
| 576 | except ValueError: |
| 577 | continue |
| 578 | return None |
| 579 | |
| 580 | |
| 581 | def _infer_years_from_range(start_date: str, end_date: str) -> List[int]: |
no outgoing calls
no test coverage detected