Created
February 20, 2018 14:39
-
-
Save marcinhlybin/6d514f65db0685021f467304ff7a3d87 to your computer and use it in GitHub Desktop.
Pendulum DST issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pendulum | |
tz = pendulum.timezone('America/Los_Angeles') | |
start_time = pendulum.parse('2018-03-11 09:00:00+00:00') | |
end_time = pendulum.parse('2018-03-11 10:00:00+00:00') | |
print((end_time - start_time).in_hours()) # 1 | |
print((end_time.in_tz(tz) - start_time).in_hours()) # 1 | |
print((end_time - start_time.in_tz(tz)).in_hours()) # 1 | |
print((end_time.in_tz(tz) - start_time.in_tz(tz)).in_hours()) # 1 | |
p1 = (end_time - start_time).in_hours() | |
print(start_time.add(hours=p1) == end_time) # True | |
print(p1) # 1.0 | |
p2 = (end_time.in_tz(tz) - start_time.in_tz(tz)).in_hours() | |
print(start_time.add(hours=p2) == end_time) # True | |
print(p2) # 1.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment