Skip to content

datetime.timestamp() takes daylight saving time into account without given timezone #155883

Description

@siegbert7

Bug report

Bug description:

# Problem: datetime.timestamp() takes DST into account without any given timezone
# Expected: datetime.timestamp() does not calculate with DST if no timezone is available
# Python 3.14.6 (tags/v3.14.6:c63aec6, Jun 10 2026, 10:26:10) [MSC v.1944 64 bit (AMD64)] on win32

from datetime import datetime as dt

dt1 = dt(2026, 3, 29, 1, 59, 59)                    # Just before Daylight Saving Time
dt2 = dt(2026, 3, 29, 3,  0,  1)                      # Just after DST

print(dt1.tzinfo, dt2.tzinfo)                         # None None                (As expected)
print(dt1)                                                    # 2026-03-29 01:59:59  (As expected)
print(dt2)                                                    # 2026-03-29 03:00:01  (As expected)
print(dt2-dt1, dt1.tzinfo, dt2.tzinfo)            # 1:00:02 None None    (As expected, 3602 seconds)

# Problem with timestamp()
dt1_ts = dt1.timestamp()
dt2_ts = dt2.timestamp()

print()
print(dt1_ts)                                       # 1774745999.0         (As expected)
print(dt2_ts)                                       # 1774746001.0         (Surprising !!!)
print(dt2_ts - dt1_ts)                              # 2.0                  (Surprising, should be 3602 seconds like (dt2-dt1) !!!)

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions