Closed dongryphon closed 2 years ago
It's an api change, in version 3 the returned objects are no longer pytz objects, but zoneinfo objects, zoneinfo being the new timezone support in the stdlib. This, and dropping Python 2 support, are the only changes from 2.1 to 3.0.
The time zone name is in the .key
attribute of the ZoneInfo object. If tzlocal didn't find a time zone name, the name will be "local"
.
Thanks for the clarification. I'll close this then.
The new 4.0b3 release uses a shim that is backwards compatible with pytz, so .zone
should work there, but with a deprecation warning. Using str(timezone)
is the new way.
Also, there is a get_localzone_name()
method if you really want a name, and not a zone.
4.0 is now released, so this should no longer be an issue, I hope.
We just got the 3.0 version and hit the above error. We are using python 3.8 and were previously using tzlocal 2.1.
Is this a regression or an API change? What is the correct way to extract the tz name using the backports module flavor?
Thanks!