fix: canonicalize numeric legacy timestamps
This commit is contained in:
parent
826874a47e
commit
b649ea7168
2 changed files with 18 additions and 0 deletions
|
|
@ -60,6 +60,8 @@ def _datetime(value: Any, default: datetime | None = None) -> datetime:
|
|||
return value if value.tzinfo else value.replace(tzinfo=timezone.utc)
|
||||
if isinstance(value, str) and value:
|
||||
return datetime.fromisoformat(value.replace("Z", "+00:00"))
|
||||
if isinstance(value, (int, float)) and not isinstance(value, bool):
|
||||
return datetime.fromtimestamp(value, tz=timezone.utc)
|
||||
return default or _now()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue