Author p-ganssle
Recipients belopolsky, dh4931, lemburg, p-ganssle, serhiy.storchaka, xtreak
Date 2020-07-20.17:09:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595264944.87.0.240337135819.issue41321@roundup.psfhosted.org>
In-reply-to
Content
Hi dh4931 — this is the expected result, assuming that the offsets changed between those two dates in your system local time.

The .timestamp() method returns an epoch time, which is the number of seconds since 1970-01-01T00:00:00 UTC, and so it is inherently timezone-aware. In Python 3, naïve datetimes went from being "unitless datetimes" to representing "local datetimes", and in certain situations (like calling `.timestamp()`), your system's time zone is used.

If you want something that gives the number of seconds that has elapsed between two naïve datetimes on the calendar and ignoring any daylight saving time transitions, subtract them directly to get a timedelta, then divide the result by a timedelta representing 1 second, like so:

    >>> (datetime.datetime(1986, 5, 4, 7, 13, 22) - datetime.datetime(1986, 5, 4, 0, 0, 0)) / datetime.timedelta(seconds=1)
    26002.0


    >>> (datetime.datetime(1986, 5, 2, 7, 13, 22) - datetime.datetime(1986, 5, 2, 0, 0, 0)) / datetime.timedelta(seconds=1)
    26002.0
History
Date User Action Args
2020-07-20 17:09:04p-gansslesetrecipients: + p-ganssle, lemburg, belopolsky, serhiy.storchaka, xtreak, dh4931
2020-07-20 17:09:04p-gansslesetmessageid: <1595264944.87.0.240337135819.issue41321@roundup.psfhosted.org>
2020-07-20 17:09:04p-gansslelinkissue41321 messages
2020-07-20 17:09:04p-gansslecreate