[issue41321] Calculate timestamp is wrong in datetime.datetime
Karthikeyan Singaravelan
report at bugs.python.org
Fri Jul 17 08:16:23 EDT 2020
Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:
Serhiy, you are right. I wrote below script that could explain the difference.
# ../backups/bpo41321.py
import datetime
import zoneinfo
for tz in zoneinfo.available_timezones():
diff = datetime.datetime(1986, 5, 4, 7, 13, 22, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp() - datetime.datetime(1986, 5, 4, 0, 0, 0, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp()
if diff != 26002:
print(diff, tz)
for tz in zoneinfo.available_timezones():
diff = datetime.datetime(1986, 5, 2, 7, 13, 22, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp() - datetime.datetime(1986, 5, 2, 0, 0, 0, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp()
if diff != 26002:
print("Diff using second day", diff, tz)
$ ./python ../backups/bpo41321.py
22402.0 Asia/Harbin
22402.0 Asia/Shanghai
22402.0 PRC
22402.0 Asia/Chongqing
22402.0 Asia/Chungking
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41321>
_______________________________________
More information about the Python-bugs-list
mailing list