CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/dst-transition-reference

Pure-reference catalog of Daylight Saving Time (DST) transition patterns and their canonical bug classes. Covers the spring-forward (skipped hour: 02:00 → 03:00 local) and fall-back (repeated hour: 02:00 → 01:00 local) transitions, the historical irregularity of DST (different jurisdictions, transitions on different dates, some regions abolish DST or never adopted it), the IANA timezone database (tz / Olson DB) as the canonical source, and the testable behaviors DST creates (duplicate / missing local timestamps, cron jobs that fire 0 or 2 times, billing periods that miss / double-count, recurring meetings on transition days). Per-jurisdiction DST-rule tables, refreshable per-region test-data fixtures, and the leap-second reference (23:59:60 insertion, time_t stalls, leap-smear vs step, monotonic-clock fixes) live in references/. Use when designing or auditing time-handling code or test cases, or when auditing leap-second assumptions.

68

Quality

86%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

leap-seconds.mdreferences/

Leap-second mechanics and bug classes

A leap second is an extra second (23:59:60 UTC) inserted to keep UTC within 0.9s of UT1. Per IERS Bulletin C (datacenter.iers.org/data/latestVersion/bulletinC.txt), insertions get ~6 months of notice. 27 were inserted 1972-2016 (most recent 2016-12-31); none since, and per the 27th CGPM resolution (2022) leap seconds will be abolished by 2035. Audit this surface only when second-granular progress matters: financial timestamping, distributed logs, NTP-sensitive schedulers.

Mechanics

PropertyDetail
FrequencyIrregular; announced by IERS Bulletin C
Insertion pointLast second of UTC June 30 or December 31
Wire format23:59:60 UTC (a real 61st second of the minute)
POSIX time_tDoes NOT include leap seconds; it stalls or jumps back 1s on insertion
NTPCarries a leap indicator; client handling varies (2012 Linux kernel-hang incident)

Whether a host inserts a real 23:59:60 or smears it over 24 hours (Google / AWS) is per-host - see smear-strategies-and-history.md. A smear is invisible to applications; a real insertion exposes the discontinuities below.

Bug classes

  1. time_t non-monotonicity - on insertion the clock stalls (1483228799 repeats) or jumps; "1s of CPU = 1s of clock" breaks.
  2. Negative durations - time.time() - start can go below zero across the insertion. Fix: monotonic clocks (time.monotonic(), clock_gettime(CLOCK_MONOTONIC)) for all duration measurement.
  3. NTP cascading - OS-dependent handling of the leap indicator.
  4. Distributed clock skew - one node steps, another smears; skew temporarily exceeds 1s. Per AWS, AWS smears specifically to avoid this.

Testable behaviours

BehaviourTest
Durations use a monotonic clocktime.monotonic() deltas stay >= 0 across the leap
Sortable timestamps don't collideSequence numbers / sub-second resolution beside stalled time_t
Cron at 00:00:00 UTC of leap dayFires exactly once
Per-host absorption strategy knownVerify step vs smear per host before comparing cross-node timestamps

Worked assertion - negative durations

start = time.monotonic()
do_work()                     # crosses 2016-12-31 23:59:60 UTC
elapsed = time.monotonic() - start
assert elapsed >= 0           # holds; the time.time() form can trip

Simulate by pinning a fake clock to the last real leap second (freeze_time('2016-12-31 23:59:59 UTC') - see the fake-clock-testing skill) and advancing across it. Caveat: fake clocks can't replay the OS-level leap indication - this asserts the code's clock choice, not the kernel's behaviour; a real leap needs an OS-level test.

Anti-patterns

Anti-patternWhy it failsFix
time.time() - start for durationsWall clock; affected by leaptime.monotonic()
Treating time_t as continuousHistorical insertions broke itPer IANA leap-seconds.list
Hardcoding 86400 seconds-per-dayOnly sometimes trueCalendar arithmetic
Assuming all servers smearSome stepVerify per-host strategy

References

SKILL.md

tile.json