Open
Description
Ran across this interesting assertion problem in some tests. Only seems to happen for fall daylight savings transitions. Basically the datetime represented as America/Los_Angeles
doesn't register as ==
to the same time represented int UTC
. The below repl example illustrates the problem.
While the datetime objects don't assert as equal, their .timestamp()
values show that they are the same.
Python 3.6.5 (default, Apr 25 2018, 14:23:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pendulum import datetime
>>> dt_a = datetime(2017, 11, 5, 1, tz='America/Los_Angeles')
>>> dt_b = datetime(2017, 11, 5, 9, tz='UTC')
>>> dt_a
DateTime(2017, 11, 5, 1, 0, 0, tzinfo=Timezone('America/Los_Angeles'))
>>> dt_b
DateTime(2017, 11, 5, 9, 0, 0, tzinfo=Timezone('UTC'))
>>> assert dt_a == dt_b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
>>> # Really? I think they are equal. Watch this! :)
...
>>> assert dt_a.timestamp() == dt_b.timestamp()