Open an42rus opened 2 months ago
We've been using isodate for many years, and oddly enough just ran into the same issue as @an42rus when switching from pytz
to zoneinfo
/ timezone.utc
.
Here's the little hack we put in place:
from isodate import DATE_EXT_COMPLETE, datetime_isoformat, TIME_EXT_COMPLETE, TZ_EXT
from datetime import timezone
if dt.tzinfo is timezone.utc:
tz_suffix = 'Z'
else:
tz_suffix = TZ_EXT
return datetime_isoformat(dt, f"{DATE_EXT_COMPLETE}T{TIME_EXT_COMPLETE}{tz_suffix}")
There is an issue with replacing of tz info from +00:00 to Z.
timezone.dst(dt) Always returns None.
It seems you need to add extra checking of dst for None value here