0

I have pendulum parsed a date string:

pendulum.parse('2015-03-09')

This object is now stored to a SqlAlchemy database table (mysql) with Column(SqlAlchemy.DateTime)

Now, I load this column value, its then:

enter image description here

Now I want to compare it back with the string date ... like this:

created.timestamp() == pendulum.parse('2015-03-09').timestamp()

which results in False ... WHAT!?

created.timestamp() -> 1425855600.0
pendulum.parse('2015-03-09').timestamp() -> 1425859200.0

Here is the pendulum parsed object FYI:

enter image description here

So why are the timestamps different?

Prutheus
  • 153
  • 15
  • 1
    At a _guess_, because the pendulum timestamp is time zone aware, but the other is not. Note that the difference between the two is 3600 -> one hour. – snakecharmerb Jun 19 '21 at 12:05
  • Okay, got it, but how to solve this? any idea? – Prutheus Jun 19 '21 at 12:09
  • 1
    The answers to [this question](https://stackoverflow.com/questions/19843203/how-to-store-a-datetime-in-mysql-with-timezone-info) may help you. – snakecharmerb Jun 19 '21 at 12:49
  • I am not allowed to change the database column – Prutheus Jun 19 '21 at 14:07
  • Then you need to make the objects comparable - perhaps the answers to [this question](https://stackoverflow.com/questions/15307623/cant-compare-naive-and-aware-datetime-now-challenge-datetime-end) may help. – snakecharmerb Jun 19 '21 at 14:13

0 Answers0