0

I am using the pytz python library.

It usually converts well from "America/Santiago" to "UTC.

The problem is that usually chile change its hour on the first saturday of september but this year it does it on the second saturday of september because there were elections.

The problem is that the pytz library did not understand that change and i am wondering if there is a way to fix this.

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
  • if you can use Python 3.9 or greater, have a look at the [zoneinfo](https://docs.python.org/3/library/zoneinfo.html) standard library. At least on UNIX OS, it obtains timezone rules from the system's zoneinfo library, which is, in many cases, updated more frequently than some Python package. However on other OS such as Windows, you'll need another 3rd party library, [tzdata](https://pypi.org/project/tzdata/). So same issue as with pytz here. – FObersteiner Nov 04 '22 at 18:07

1 Answers1

3

You likely need to update pytz to use the latest version.

Check out their changelog here: https://github.com/stub42/pytz/blob/master/tz/NEWS#L174 - it looks like in August they updated the library to support this change in Chile's daylight savings.

Tyler Aldrich
  • 386
  • 2
  • 10
  • hi @Tyler Aldrich, i also having the same issue with the pendulum library. I cannot use pytz instead because its being used widely in the project i am. Please could you take a look at my new post about it? Many thanks. https://stackoverflow.com/questions/74349967/pytz-dataobject-is-not-being-handled-ok-by-the-pendulum-library . The thing is it does not look pendulum has fixed its library. – Víctor Rosillo Nov 07 '22 at 17:18
  • 1
    Hi @VíctorRosillo, I took a look really quickly and it looks like Pendulum hasn't been updated since 2020 and still relies on the `pytzinfo` package https://pypi.org/project/pytzdata/ which is also out of date and was replaced with https://pypi.org/project/tzdata/ for timezone data. The Pendulum maintainers have made updates to the library but haven't published a new version - you can see if the latest repo version works by pip installing like `python3 -m pip install Pendulum@git+https://github.com/sdispater/pendulum.git@f712af4` to install the latest revision. – Tyler Aldrich Nov 07 '22 at 19:08