This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: possible bug in datetime.timestamp()
Type: behavior Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: p-ganssle, stef
Priority: normal Keywords:

Created on 2021-10-14 16:42 by stef, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg403917 - (view) Author: Stefan (stef) Date: 2021-10-14 16:42
I noticed that there is a difference between intervals when computed from timedeltas vs timestamps. Is this a bug? Thanks!

In [2]: import datetime as datet
In [3]: d0 = datet.datetime(2016,3,27)
In [4]: d1 = datet.datetime(2016,3,28)
In [5]: (d1-d0).total_seconds()/3600
Out[5]: 24.0
In [6]: (d1.timestamp()-d0.timestamp())/3600
Out[6]: 23.0
msg403922 - (view) Author: Stefan (stef) Date: 2021-10-14 17:10
sorry it's resolved. it was a timezone issue:

In [2]: d0 = datet.datetime(2016,3,27,tzinfo=datet.timezone.utc)

In [3]: d1 = datet.datetime(2016,3,28,tzinfo=datet.timezone.utc)

In [4]: (d1-d0).total_seconds()/3600
Out[4]: 24.0

In [5]: (d1.timestamp()-d0.timestamp())/3600
Out[5]: 24.0
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89633
2021-10-14 17:10:45stefsetstatus: open -> closed

messages: + msg403922
stage: resolved
2021-10-14 17:07:08corona10setnosy: + p-ganssle
2021-10-14 16:42:55stefcreate