(value: Any)
| 302 | |
| 303 | |
| 304 | def _normalize_datetime(value: Any) -> Optional[datetime]: |
| 305 | if value is None: |
| 306 | return None |
| 307 | if isinstance(value, datetime): |
| 308 | if value.tzinfo is None: |
| 309 | return value.replace(tzinfo=timezone.utc) |
| 310 | return value.astimezone(timezone.utc) |
| 311 | number = _to_float(value) |
| 312 | if number is not None: |
| 313 | return _try_parse_epoch(number) |
| 314 | if isinstance(value, str): |
| 315 | raw = value.strip() |
| 316 | if not raw: |
| 317 | return None |
| 318 | try: |
| 319 | if raw.endswith("Z"): |
| 320 | raw = raw[:-1] + "+00:00" |
| 321 | dt = datetime.fromisoformat(raw) |
| 322 | if dt.tzinfo is None: |
| 323 | dt = dt.replace(tzinfo=timezone.utc) |
| 324 | return dt.astimezone(timezone.utc) |
| 325 | except ValueError: |
| 326 | return None |
| 327 | return None |
| 328 | |
| 329 | |
| 330 | def _format_duration(seconds: Optional[float]) -> str: |
no test coverage detected