regebro / tzlocal

A Python module that tries to figure out what your local timezone is

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

On Android/Termux, tzdata should be added as a requirement

Neo-Oli opened this issue · comments

commented

I am using tzlocal with khal. Sometimes recently the dependency of tzdata was dropped somewhere in that dependency stack, but tzlocal really needs it on Android/Termux. Manually adding the tzdata dependency fixes the problem, but it should be added to tzlocal as a dependency on the Android/Termux, just like Windows.

tzdata; platform_system == "Windows"

Stacktrace:

  File "/data/data/com.termux/files/home/loc/virtualenvs/khal/lib/python3.11/site-packages/tzlocal/unix.py", line 218, in get_localzone
    _cache_tz = _get_localzone()
                ^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/loc/virtualenvs/khal/lib/python3.11/site-packages/tzlocal/unix.py", line 175, in _get_localzone
    tzenv = utils._tz_from_env()
            ^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/loc/virtualenvs/khal/lib/python3.11/site-packages/tzlocal/utils.py", line 110, in _tz_from_env
    raise zoneinfo.ZoneInfoNotFoundError(
zoneinfo._common.ZoneInfoNotFoundError: 'tzlocal() does not support non-zoneinfo timezones like Europe/Zurich. \nPlease use a timezone in the form of Continent/City

The problem is that Android is Linux, so this isn't doable, as we can't distinguish Android from other Linuxes. You just need to add it as a dependency to your Android package.