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

Difference between timezones is always 0 #389

Closed
matcool opened this issue Jul 22, 2019 · 1 comment
Closed

Difference between timezones is always 0 #389

matcool opened this issue Jul 22, 2019 · 1 comment

Comments

@matcool
Copy link

matcool commented Jul 22, 2019

I wanted to check the hours difference between two timezones, but instead I got 0
Example: (this happens with any two timezones)

>>> a = pendulum.now('America/New_York')
>>> b = pendulum.now('Europe/Berlin')
>>> a.diff(b).in_hours()
0
@zeebonk
Copy link

zeebonk commented Jul 30, 2019

Hi @matcool, I'm not one of the maintainers, but might be able to help you out:

dt1.diff(dt2) return time time between the moments that d1 and d2 occur. As you're specifically asking for now, but in two different timezones, it will be the same 'moment' of time, and therefore difference is 0.

To look it from a different angle, if you would screen "HEY" now while being in New York, and I would screen "HEY" now while being in Berlin, we will be screaming "HEY" at the same time: 0 hours difference.

If you want the difference in timezone offsets, you can use the offset property, which specifies the +/- number of seconds offset from UTC:

In [14]: (pendulum.now('Europe/Berlin').offset - pendulum.now('America/New_York').offset) / 3600
Out[14]: 6.0

@matcool matcool closed this as completed Jul 30, 2019
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

2 participants