kennethreitz / maya

Datetimes for Humans™
MIT License
3.41k stars 196 forks source link

Package not compatible with next version of tzlocal #191

Open pganssle opened 4 years ago

pganssle commented 4 years ago

The next version of tzlocal will switch from using pytz zones to zoneinfo (which is generally a good idea), which will break this package, since zoneinfo zones don't have the same interface as pytz zones.

You should probably pin the version of tzlocal ASAP, and/or add in some logic to detect zoneinfo zones and convert them to whatever you want.

In the longer term, you should probably also migrate away from pytz and on to zoneinfo. I have a pytz-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).

KPrasch commented 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'