Open pganssle opened 4 years ago
Possibly related - I just updated tzlocal to version 3.0b1 and am not able to use the .local_datetime()
method producing:
>>> import maya
>>> now = maya.now()
>>> now.local_datetime()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/kieran/.local/share/virtualenvs/nucypher-9CH2v_st/lib/python3.8/site-packages/maya/core.py", line 267, in local_datetime
return self.datetime(to_timezone=self.local_timezone, naive=False)
File "/home/kieran/.local/share/virtualenvs/nucypher-9CH2v_st/lib/python3.8/site-packages/maya/core.py", line 182, in local_timezone
if self._local_tz.zone in pytz.all_timezones:
AttributeError: 'backports.zoneinfo.ZoneInfo' object has no attribute 'zone'
@property
def local_timezone(self):
"""Returns the name of the local timezone."""
> if self._local_tz.zone in pytz.all_timezones:
E AttributeError: 'backports.zoneinfo.ZoneInfo' object has no attribute 'zone'
The next version of
tzlocal
will switch from usingpytz
zones tozoneinfo
(which is generally a good idea), which will break this package, sincezoneinfo
zones don't have the same interface aspytz
zones.You should probably pin the version of
tzlocal
ASAP, and/or add in some logic to detectzoneinfo
zones and convert them to whatever you want.In the longer term, you should probably also migrate away from
pytz
and on tozoneinfo
. I have apytz-deprecation-shim
module that should help ease the pain (though it is not 100% backwards compatible - in the migration guide you'll find that the semantics of datetime addition are slightly different).