Description
Is your feature request related to a problem? Please describe.
I find pytz
to be somewhat confusing and cumbersome. Since Python 3.9, pytz
can be replaced by the standard library's zoneinfo package for full and up-to-date IANA timezone support. Furthermore, it appears that localization of "naive" timedate
timestamps is fully supported without using pytz
. For example:
import datetime
from pprint import pprint
import zoneinfo
pprint(zoneinfo.available_timezones())
time_naive = datetime.datetime(1974, 6, 22, 18, 30, 15)
print(time_naive)
time_aware = time_naive.replace(tzinfo=zoneinfo.ZoneInfo("Etc/GMT+5"))
print(time_aware)
print(time_aware.astimezone(zoneinfo.ZoneInfo("UTC")))
In particular, the pvlib.location.Location
class can be streamlined significantly by using only the zoneinfo.ZoneInfo
class as the timezone attribute. Of course, pytz
would still be lurking in the background due to its significant usage in pandas
.
Describe the solution you'd like
Switch from pytz
to zoneinfo
. We could optionally deprecate pytz
usage initially in the pvlib.location.Location
constructor, but my sense is that simply removing it entirely will not break many people who typically instead use timezone strings in the initializer. Also, https://pvlib-python.readthedocs.io/en/latest/user_guide/timetimezones.html would need a significant update.
Describe alternatives you've considered
Keep using pytz
.
Additional context
See #2339 #2343 for an example of pytz
's full removal.
Activity