I have a 2 datetimes from "America/Santiago" timezone:
- 2022-09-04 00:00:00
- 2022-09-04 01:00:00
In "America/Santiago" they usually change the hour on the 4th Sept. This is at 2022-09-04 00h they say it is 2022-09-04 01:00:00. But this year because of elections the change of hour was delayed one week. So there is no change of time on the 4th.
I need to convert the chilean time to UTC. Therefore:
By using an updated version of pytz library, i succeed to convert this to a datetime object in "UTC":
- 2022-09-04 00:00:00-04:00
- 2022-09-04 01:00:00-04:00
The old version i was using did not had this into count because did not know about it.
The problem is that i want to generate too and end time so the script i am reviewing from my department is using the following pendulum library:
def my_next_hour(datetime_obj):
//datetime_obj=2022-09-04 00:00:00-04:00
new_dt = pendulum.instance(datetime_obj).add(hours=1)
return new_dt
The output i get is:
- 2022-09-04T02:00:00-03:00
- 2022-09-04T02:00:00-03:00
As it can be seen, on the first record i do not know why it changes the -4 to -3. Anyway at the end it does the job. But as a consequence in the second record i do not get the plus hour.
So i am asking to understand how to upload pendulum to possibly update as well the library in the same way pytz did to correct the change of time in a week later that usual.
I do not want if i can avoid it to use another library because the code i am reviewing is using in other parts as well the library, so the idea is to fix the library not every operation.
Thanks