Fix NPMplus expiry timezone handling
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user