Fix NPMplus expiry timezone handling

This commit is contained in:
2026-02-08 00:41:09 +03:00
parent d007f6064b
commit c89e7259f6

View File

@@ -14,8 +14,12 @@ def _parse_expiry(value: str | None) -> datetime | None:
cleaned = value.strip() cleaned = value.strip()
try: try:
if cleaned.endswith("Z"): if cleaned.endswith("Z"):
return datetime.fromisoformat(cleaned.replace("Z", "+00:00")) dt = datetime.fromisoformat(cleaned.replace("Z", "+00:00"))
return datetime.fromisoformat(cleaned) else:
dt = datetime.fromisoformat(cleaned)
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
return dt
except ValueError: except ValueError:
for fmt in ("%Y-%m-%d %H:%M:%S", "%Y-%m-%d"): for fmt in ("%Y-%m-%d %H:%M:%S", "%Y-%m-%d"):
try: try: