Open Mcklmo opened 1 month ago
I have a similar issue.
When working with pendulum and dst, I ran into this issue:
str(pendulum.parse("2024-10-27 02:00:00", tz="Europe/Copenhagen")) '2024-10-27 02:00:00+01:00' str(pendulum.parse("2024-10-27 02:00:00", tz="Europe/Copenhagen").subtract(minutes=15)) '2024-10-27 02:45:00+02:00' <-- Why does this end as 02:00 ? If "2024-10-27 02:00:00" = '2024-10-27 02:00:00+01:00' I would expect str(pendulum.parse("2024-10-27 02:00:00", tz="Europe/Copenhagen").subtract(minutes=15)) to be equal = '2024-10-27 01:45:00+01:00'
I can get the expected value using: str(pendulum.parse("2024-10-27 02:00:00", tz="Europe/Copenhagen").replace(fold=0).subtract(minutes=15)) '2024-10-27 01:45:00+02:00'
But I seems like a "stupid" hack.
Issue
The fold attribute behaves weirdly when adding different timedeltas to a datetime object. Adding minutes changes the fold from 0 to 1. Adding days keeps it at 1.
On the other hand, when setting fold to 0, adding minutes preserves it, and adding days changes it.
It seems like adding minutes forces the fold attribute to be 0 and days forces it to be 1.