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:
@@ -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")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user