fixed date formatting in the JSON
This commit is contained in:
parent
57f17bb04e
commit
4e25d4a68e
1 changed files with 6 additions and 0 deletions
|
|
@ -45,6 +45,7 @@ def parse_iso(value: Any) -> Optional[str]:
|
|||
Best-effort: return ISO8601 string or None.
|
||||
- If value is already a string, return it (assuming it's already ISO8601).
|
||||
- If value looks like 'ISODate(\"...\")', extract the inner string.
|
||||
- If value is Extended JSON format { "$date": "..." }, extract the date string.
|
||||
- Otherwise, return None.
|
||||
"""
|
||||
if value is None:
|
||||
|
|
@ -53,6 +54,11 @@ def parse_iso(value: Any) -> Optional[str]:
|
|||
# Handle Mongo shell export style: ISODate('2025-07-09T06:33:12.682Z')
|
||||
m = re.match(r"^ISODate\(['\"]?([^'\"]+)['\"]?\)$", value.strip())
|
||||
return m.group(1) if m else value
|
||||
# Handle Extended JSON format: { "$date": "2025-07-09T06:33:12.682Z" }
|
||||
if isinstance(value, dict) and "$date" in value:
|
||||
date_val = value["$date"]
|
||||
if isinstance(date_val, str):
|
||||
return date_val
|
||||
# Could try to parse datetime objects here if needed; for now, prefer string passthrough
|
||||
return None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue