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

Subtracting negative timedelta around DST not same as adding the positive #420

Closed
tomage opened this issue Oct 25, 2019 · 3 comments
Closed

Comments

@tomage
Copy link
Contributor

tomage commented Oct 25, 2019

Hey! As I've been digging deeper into the Pendulum library, I've discovered one interesting edge-case: Namely that for specific times, subtracting a negative timedelta is not the same as adding the positive one.

Thus, my_dt - my_negative_timedelta is not equal to my_dt + (-my_negative_timedelta).

As before, I took the liberty of throwing together what seemed a sensible patch: #419.

Here's also a pyfiddle, to see this in action: https://pyfiddle.io/fiddle/6a20e200-bb3a-4af9-b336-a216f868487d/.

Thanks!

@teresatruex
Copy link

I am seeing the same issue! Is this a bug? Please let us know!

@shuyang-truex
Copy link

I'm experiencing the same issue, my code snippet below:

import pendulum
from pendulum import datetime
from datetime import timedelta

la_tz = pendulum.timezone('America/Los_Angeles')

d = datetime(2019, 11, 4, hour=0, tzinfo=la_tz)

and console output:

>>> d - timedelta(hours=24)
<Pendulum [2019-11-03T00:00:00-07:00]>
>>> d + timedelta(hours=-24)
<Pendulum [2019-11-03T01:00:00-07:00]>

Hope we can get some attention from the maintainers on this issue.

@tomage
Copy link
Contributor Author

tomage commented Jul 5, 2020

Fixed with #419 (comment)!

@tomage tomage closed this as completed Jul 5, 2020
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

3 participants