(paper: Dict[str, Any])
| 224 | |
| 225 | |
| 226 | def _parse_publish_month(paper: Dict[str, Any]) -> datetime: |
| 227 | for key in ("publish_date", "published", "updated", "created_at", "fetched_at"): |
| 228 | raw = _clean_text(paper.get(key)) |
| 229 | if not raw: |
| 230 | continue |
| 231 | for fmt, width in (("%Y-%m-%d", 10), ("%Y/%m/%d", 10), ("%Y-%m", 7), ("%Y/%m", 7)): |
| 232 | try: |
| 233 | return datetime.strptime(raw[:width], fmt) |
| 234 | except ValueError: |
| 235 | continue |
| 236 | match = re.search(r"(20\d{2})[-/](\d{1,2})", raw) |
| 237 | if match: |
| 238 | year = int(match.group(1)) |
| 239 | month = max(1, min(12, int(match.group(2)))) |
| 240 | return datetime(year, month, 1) |
| 241 | return datetime.now() |
| 242 | |
| 243 | |
| 244 | def _month_folder_name(paper: Dict[str, Any]) -> str: |
no test coverage detected