Fixed timezone being returned incorrectly

Happened if you've set TZ to non-UTC.

Apparently astimezone and replace doesn't do the same thing even if tzinfo is None.
This commit is contained in:
Donkie
2023-10-02 21:35:46 +02:00
parent e07436bd8c
commit 205574fa2c
7 changed files with 30 additions and 5 deletions

View File

@@ -13,7 +13,7 @@ from spoolman.math import length_from_weight
def datetime_to_str(dt: datetime) -> str:
"""Convert a datetime object to a string."""
if dt.tzinfo is None:
dt = dt.astimezone(tz=timezone.utc)
dt = dt.replace(tzinfo=timezone.utc)
return dt.isoformat().replace("+00:00", "Z")