Ask HN Digest Weekly HN signal

The Imminent Challenge of the Negative Leap Second

Managing time in software is famously difficult, and the prospect of the first-ever negative leap second—where a second is skipped entirely—has highlighted systemic vulnerabilities in how we track duration and events. While positive leap seconds have historically caused issues by momentarily repeating a second, a negative leap second introduces new complexity: time effectively skipping forward, potentially confusing systems that rely on linear, monotonically increasing timestamps.

Why Time Standards Clash

The confusion stems from the fundamental conflict between three desirable but mathematically incompatible goals: 1. Days of exactly 86,400 seconds. 2. Solar alignment (noon occurs when the sun is at its zenith). 3. Using SI seconds (for scientific uniformity).

Because these cannot all be perfectly maintained, organizations must choose which one to sacrifice. This leads to the emergence of "leap smearing," where providers spread the leap second adjustment over an entire day. While this keeps systems from experiencing a sudden time jump, it complicates scenarios where high-precision synchronization is required across different servers or organizations using different smearing policies.

Tactical Recommendations for Developers

The consensus among engineers is that manual time arithmetic is a dangerous practice. Instead, the following best practices should be prioritized:

  • Avoid Manual Epoch Arithmetic: Never assume a day has exactly 86,400 seconds, and do not attempt to write custom leap-second handling logic. Utilize robust, well-maintained date-time libraries that account for these edge cases.
  • Use Monotonic Clocks for Intervals: If your goal is to measure the duration of a task or the elapsed time between operations, never rely on wall-clock time (gettimeofday). Always use monotonic timers, which are designed to increase steadily regardless of system clock adjustments or synchronization events.
  • Anticipate Failures: Systems that rely on timestamps for billing, job scheduling, or database ordering should be designed to be resilient against time jumps or duplicates. Defensive programming, such as using atomic sequencing or relying on external authoritative time sources (like PTP for sub-millisecond requirements), is essential for safety-critical environments.

The Future of Timekeeping

The current reliance on leap seconds and varying smearing techniques is increasingly viewed as technical debt. International efforts are underway to move away from these methods by 2035, likely transitioning toward larger, less frequent adjustments—such as "leap minutes"—or abandoning solar-noon precision entirely for civil time. For developers, the prevailing philosophy is simple: abstract these complexities away through libraries, rely on monotonic clocks for internal operations, and recognize that attempting to force perfect solar-to-clock alignment is often a losing battle for digital infrastructure.

Get the most interesting Hacker News discussions delivered as a weekly brief.