How Daylight Saving Time Causes Duplicate and Missing Hours

Written by Raheel Ikram | Updated December 5, 2026 | Reading time: 5 minutes

Adding 86400 seconds to a local calendar event fails twice every year in countries that observe Daylight Saving Time (DST). On transition weekends, a local 9:00 AM daily alarm shifts to 8:00 AM or 10:00 AM because not every civil day lasts 24 hours.

Two DST Edge Cases That Break Software

How to Fix DST Bugs in Python and Databases

Never compute recurring civil calendar events by adding 86400 to a Unix timestamp. Instead, store the local wall time plus the IANA timezone name, then recalculate the Unix integer for each date using a timezone-aware library. In Python, the fold attribute (introduced in PEP 495) distinguishes between the first (fold=0) and second (fold=1) pass of a repeated local hour.

from datetime import datetime
from zoneinfo import ZoneInfo

ny = ZoneInfo("America/New_York")
first_pass = datetime(2026, 11, 1, 1, 30, tzinfo=ny, fold=0)
second_pass = datetime(2026, 11, 1, 1, 30, tzinfo=ny, fold=1)

print(int(first_pass.timestamp()), int(second_pass.timestamp()))
# Difference is exactly 3600 seconds
About the Author: Raheel Ikram

Creator of Timestamp Converter, writing practical guides on timekeeping, SQL schema design, and web utilities. Read full bio.