Calling the method timestamp at the last Sunday of march returns:
>>> import datetime
>>> before = datetime.fromisoformat("2023-03-26 02:00:01")
>>> after = datetime.fromisoformat("2023-03-26 03:00:01")
>>> print(before.tzinfo)
None
>>> print(after.tzinfo)
None
>>> after.timestamp() - before.timestamp()
0.0
They are equal even they are separated by an hour. I was expecting that daylight saving time was not handled when tzinfo is None
Meanwhile, when using the subtract operator, it catches the difference
>>> after - before
datetime.timedelta(seconds=3600)
https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp
"naive" means without tzinfo, so the
timestampmethod implicitly treats them as local time, hence the zero difference you see.Meanwhile the
after - beforedate math treats them as abstract datetimes with no timezone, so the resulting timedelta does not take DST into account.