MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _parse_publish_month

Function _parse_publish_month

agents/reading-agent/main.py:226–241  ·  view source on GitHub ↗
(paper: Dict[str, Any])

Source from the content-addressed store, hash-verified

224
225
226def _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
244def _month_folder_name(paper: Dict[str, Any]) -> str:

Callers 4

_month_folder_nameFunction · 0.85
_daily_note_folder_nameFunction · 0.85
_daily_note_file_nameFunction · 0.85

Calls 3

getMethod · 0.80
nowMethod · 0.80
_clean_textFunction · 0.70

Tested by

no test coverage detected