-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace pytz with standard library's zoneinfo #2342
Comments
I confess this is the first I've heard of zoneinfo, but it seems like the python community at large is agreed that switching from pytz to zoneinfo is a good idea. Thanks @markcampanelli for bringing it up! I'm seeing some people saying that Windows doesn't include a tz database by default. Depending on
Good point, although it looks like pandas 3.0 will make pytz an optional dependency (pandas-dev/pandas#59089). |
@kandersolar Did you happen to discover if there was a more explicit way to "localize" a datetime using time_naive = datetime.datetime(1974, 6, 22, 18, 30, 15)
time_aware = time_naive.replace(tzinfo=zoneinfo.ZoneInfo("Etc/GMT+5")) |
It seems like this is only with significantly out of date Windows installations. All the Windows tests added in #2341 that use |
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 usingpytz
. For example:In particular, the
pvlib.location.Location
class can be streamlined significantly by using only thezoneinfo.ZoneInfo
class as the timezone attribute. Of course,pytz
would still be lurking in the background due to its significant usage inpandas
.Describe the solution you'd like
Switch from
pytz
tozoneinfo
. We could optionally deprecatepytz
usage initially in thepvlib.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 ofpytz
's full removal.The text was updated successfully, but these errors were encountered: