Skip to content
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

Comparing DateTimes before- and after-the-fold returns incorrect result #855

Open
2 tasks done
itaiperi opened this issue Oct 30, 2024 · 0 comments
Open
2 tasks done

Comments

@itaiperi
Copy link

itaiperi commented Oct 30, 2024

  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: MacOS Sonoma 14.5
  • Pendulum version: 3.0.0

Issue

There's a problem when comparing dates which are in the same timezone, but have different offsets due to daylight savings in the fold. Basically, daylight savings are not taken into account in the fold.
In the following example, d1 is after the fold, meaning it was 2:15 AM and was moved back to 1:15 AM, which should be after 1:25 AM before the fold.
However, simply comparing d1 to d2 with d1 < d2 returns True, whereas d1.timestamp() < d2.timestamp() returns the correct result, False.

Example:

d1 = pendulum.datetime(2023, 11, 5, 1, 15, 0, 0, tz="America/Los_Angeles", fold=1)
d2 = pendulum.datetime(2023, 11, 5, 1, 25, 0, 0, tz="America/Los_Angeles", fold=0)

print(d1 < d2) # True
print(d1.timestamp() < d2.timestamp()) # False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant