Deep DivesLeap Seconds

The Deal We Made with the Sun

Leap seconds - The Problem & The Two Clocks
Do you know our days aren't exactly 24 hours? They're a few milliseconds longer, and growing. The culprit is the Moon, and the solution nearly broke the internet.

00

The Problem & The Two Clocks

The Moon's gravity pulls on Earth's oceans, creating two bulges of water that circle our planet.
Key Fact

Tidal Friction: Every century, we lose 1.7 milliseconds of rotational speed

As Earth rotates beneath these tidal bulges, friction occurs—imagine dragging your hand through water. This friction slows our spin, like a brake pad on a wheel.

Every century, we lose 1.7 milliseconds of rotational speed, and this energy is transferred to the Moon, pushing it 3.8 centimeters farther away each year.

EarthRotationTidal BulgeMoonGravitational PullFriction Slows RotationMoon Drifts Away3.8 cm/year
Tidal friction: Earth slows, Moon drifts away
“By the late 1960s, this created a measurement crisis. We had two clocks that fundamentally disagreed.”

We had two fundamentally different ways to measure time, and they were drifting apart.

Key Concept

Two Time Standards: TAI (atomic perfection) vs UT1 (Earth's actual rotation)

TAI (Temps Atomique International): A cesium-133 atom vibrates 9,192,631,770 times per second, always, exactly, without variation. Since 1958, TAI has never stopped, never adjusted, never looked outside itself. Today, over 450 atomic clocks in 80 laboratories contribute to its calculation.

UT1 (Universal Time): Tracks Earth's actual rotation. It's what sundials measure with the real position of the Sun in the sky. But the Earth isn't a reliable timekeeper. Earthquakes shift mass, melting glaciers redistribute water, and even wind patterns change our spin.

TAI
Atomic Time
0s1s2s3s4s5s6s7s8s9s10s
Perfect, constant, never varies
UT1
Earth Rotation
0s1s2s3s4s5s6s7s8s9s10s
Variable, depends on Earth's actual rotation
TAI: Perfectly uniform. UT1: Wobbles with Earth's rotation
SOLAR TIMEApparent or TrueEPHEMERIS TIMEMore stable than Solar TimeUNIVERSAL TIME(UT)Mean Solar TimeATOMIC TIME(AT)Constant via Atomic ClocksINTERNATIONALATOMIC TIME(TAI)More stable than ATPhaseFrequencyUNIVERSALCOORDINATED TIME(UTC)Compromise betweenAtomic Time + Solar TimeTERRESTRIAL TIME(TT)Idealized version of TAI,independent from Earth
The evolution and relationships of modern time standards
“The two clocks drift apart by about 0.6 seconds per year. Without correction, they would diverge until noon arrived at midnight.”

01

The Compromise: UTC

Leap seconds - The Compromise: UTC
UTC (Coordinated Universal Time) bridges the gap between atomic perfection and Earth's messy reality.
Key Solution

Leap Seconds: When UTC drifts ±0.9 seconds from UT1, we pause for one second

Invented in 1972, UTC uses atomic seconds but keeps them aligned with Earth's rotation. The rule is simple: when UTC drifts ±0.9 seconds from UT1, add a leap second at 23:59:60, letting Earth catch up.

Normal Second Progression
23:59:58
23:59:59
00:00:00
With Leap Second
23:59:58
23:59:59
23:59:60
00:00:00
The extra second that shouldn't exist

We've added 27 leap seconds since 1972. Each one represents our planet slowing down, the Moon drifting away, and humanity's attempt to reconcile the precision of atoms with the wandering of worlds.

“Currently in 2025: UTC = TAI - 37 seconds. That's 10 initial seconds plus 27 leap seconds we've added since 1972.”

Exercise 1

UTC Drift Calculator

See how UTC and UT1 drift apart over time and understand why we need leap seconds.

The Drift

Earth's rotation slows by ~1.7ms per century due to tidal friction. UTC (atomic time) and UT1 (Earth time) drift apart by about 0.6 seconds per year on average.

The Threshold

When the drift reaches ±0.9 seconds, IERS adds a leap second. This keeps UTC within 0.9s of solar time so noon stays near actual solar noon.

Try it: Drag the slider to see how many leap seconds would be needed over different time periods. Notice how solar noon would drift!

50 years
30.0s
Total Drift
33
Leap Seconds

UTC vs UT1 Drift

±30.00s
Max allowed drift: 0.9 seconds

After 50 years, 33 leap seconds would be needed. Solar noon would be off by 0.3 minutes.

02

The Algorithm of Alignment

Leap seconds - The Algorithm of Alignment
When IERS decides Earth needs another second, the process begins six months in advance.
Key Process

Six-Month Notice: IERS issues Bulletin C when drift approaches 0.6 seconds

When a leap second occurs, here's what actually happens:

TAI (keeps counting)
...58 → ...59 → ...00 → ...01 → ...02
UTC (pauses for one second)
...58 → ...59 → ...60 → ...00 → ...01
UT1 (Earth's rotation catches up)
Earth's rotation catches up during the pause

The pattern tells a story. The 1970s needed almost annual corrections. Then intervals stretched. The seven-year gap from 1999-2005 shocked timekeepers. Now we're in the longest pause yet: over eight years since 2016.

Leap Seconds History
1972-1979
~1 per year
1981-1999
1-3 year gaps
1999-2005
7 year gap!
2005-2016
Variable
2016-2025
8+ years (none!)
27 leap seconds added since 1972
“Each leap second represents 1.7 milliseconds per day of accumulated drift, roughly 620 milliseconds per year.”

03

When Time Goes Backwards: Chaos in Production

Leap seconds - When Time Goes Backwards
That one extra second sounds harmless, but on June 30, 2012, the internet partially collapsed.
Key Problem

Timestamp Collision: The same second occurs twice, breaking uniqueness

Most software assumes time moves forward continuously with 86,400 seconds per day. Many systems represent time as seconds since the Unix epoch: January 1, 1970, 00:00:00 UTC.

During a positive leap second, something impossible happens—the same timestamp occurs twice:

time(23:59:59)
=
1483228799
time(23:59:60)
=
1483228799
← Same timestamp twice!
time(00:00:00)
=
1483228800

The bug was in the Linux kernel's futex subsystem. When the leap second hit, threads waiting on futexes spun at 100% CPU usage. Reddit went down. Mozilla's servers crashed. Qantas Airways' check-in system failed, stranding passengers worldwide.

The fix was embarrassingly simple: just setting the date to itself cleared the deadlock. But the damage was done—millions of dollars lost in minutes.

“Our entire digital infrastructure assumes time never stops, never repeats, never goes backward. The leap second violates all three assumptions simultaneously.”

The leap second's impact ripples far beyond crashed servers.

Key Impact

Microsecond Precision: HFT systems execute thousands of trades per second

Modern systems demand microsecond precision. FINRA requires microsecond timestamps on all trades, and EU MiFID II mandates 100-microsecond accuracy. When time stutters, trades execute out of order and prices diverge across exchanges.

The problem multiplies in distributed systems. Imagine a database cluster with three servers during a leap second:

Server A
Steps clock backward
23:59:59 happens twice
Server B
Pauses at 23:59:59
Clock stops for one second
Server C
Ignores leap second
Jumps straight to 00:00:00
Result: Servers disagree about what happened when
A customer's withdrawal might appear before their deposit
“Some stock exchanges took no chances. They halted trading for 61 minutes around the leap second, treating time itself as a systemic risk.”

04

Why Is This So Hard To Fix?

Leap seconds - Why Is This So Hard To Fix?
The complexity isn't technical—it's systemic.
Key Challenge

Legacy Systems: Banking mainframes from the 1970s still process trillions

Legacy systems: Banking mainframes from the 1970s still process trillions in transactions. Updating them risks everything.

Distributed complexity: Google alone has millions of servers across hundreds of data centers. Ensuring they all handle leap seconds identically is nearly impossible.

Lack of standards: UTC defines when to add leap seconds, but not how systems should implement them. Every vendor invented their own solution.

Rare events: Leap seconds happen every few years, irregularly. Bugs lie dormant until the critical moment, untested and unnoticed.

“Faced with an unsolvable problem, engineers did what engineers do: they built workarounds.”

05

Engineering Around Failure

Leap seconds - Engineering Around Failure
Each solution works, but they're mutually incompatible, creating new chaos.
Key Workaround

Google's Leap Smear: Spreads the extra second across 24 hours

Google's Leap Smear spreads the extra second across 24 hours. Instead of 23:59:60, they slow every second by 0.0011574%:

Normal second: 1.0000000 seconds
Smeared second: 1.0000116 seconds
Total drift: 86,400 × 0.0000116 = 1 second

Trade-off: For 24 hours, Google's time doesn't match UTC

Clock Stepping is the traditional approach. The kernel repeats 23:59:59 or jumps backward one second. It triggered the 2012 Linux disaster.

The Ostrich Algorithm: Windows and many IoT devices simply ignore leap seconds. Their clocks drift up to one second from UTC until the next NTP sync.

TAI Internally: Financial firms increasingly run on TAI or GPS time internally, converting to UTC only for display:

GPS time = UTC + 18 seconds (as of 2025)
TAI = UTC + 37 seconds
GPS time = TAI - 19 seconds (constant since 1980)
“Every workaround solves one problem while creating another. We've replaced one universal time with dozens of slightly different times.”

Exercise 2

Leap Second Strategies

Compare different approaches to handling leap seconds and understand their trade-offs.

Google's Smear

Spreads the extra second over 24 hours by running clocks 0.0011574% slower. Avoids time jumps but creates temporary disagreement with UTC.

Clock Stepping

Traditional approach: add 23:59:60 or repeat 23:59:59. Stays synchronized with UTC but caused the 2012 Linux disaster.

Ignore Strategy

Windows and many IoT devices simply skip the leap second. Simple but creates drift until next NTP sync.

Try it: Switch between strategies to see their timelines and understand why each approach has different implications for distributed systems.

Google Leap Smear

Spreads 1 second over 24 hours

Timeline

00:00:00
Smear begins
Each second = 1.0000116s
12:00:00
Halfway
0.5 seconds smeared
23:59:59
Smear complete
Full second absorbed
00:00:00
Back to normal
Clock rate returns to 1s/s
⚖️

Pro: No time jumps. Con: Clock doesn't match UTC for 24 hours.

06

The Future: Negative Seconds & The End of Precision

Leap seconds - The Future: Negative Seconds
For fifty years, leap seconds obeyed a single rule: Earth slows, we add time. Then, in 2020, the ratchet tried to reverse.
Key Discovery

Earth Sped Up: June 29, 2022, was 1.59 milliseconds under 24 hours

June 29, 2022, became the shortest day since atomic timekeeping began. The planet that had reliably decelerated for centuries suddenly spun faster.

A negative leap second would delete 23:59:59 entirely:

What we built for (Positive)
23:59:58
23:59:59
23:59:60
00:00:00
What might happen (Negative)
23:59:58
23:59:59
SKIP
00:00:00
No operating system contains code for this deletion

No operating system contains code for this deletion. Every timer, every scheduler, every database assumes 23:59:59 exists. While a positive leap second creates two identical timestamps, a negative leap second creates a temporal hole.

“Current models project the potential need by 2029 as the Earth's acceleration has slowed but not reversed.”

In November 2022, the General Conference on Weights and Measures passed Resolution 4 to abolish leap seconds by or before 2035.

Key Decision

2035 Deadline: Leap seconds will be abolished, allowing UTC-UT1 to grow

The new plan allows |UT1-UTC| to grow beyond 0.9 seconds. The exact limit remains undecided; proposals range from one minute to one hour.

Consider what happens as the offset grows:

2035
UTC-UT1 = 1 second (threshold breached)
2055
UTC-UT1 = 20 seconds (noon off by 1.3 minutes)
2135
UTC-UT1 = 100 seconds (noon off by 6.7 minutes)
2635
UTC-UT1 = 1 hour (noon at 1 PM solar time)

Three solutions compete to replace leap seconds:

Leap Minutes: Add 60 seconds at once, perhaps every 50-100 years. Predictable, but every system worldwide loses an entire minute simultaneously.

Continuous Smearing: Adjust clock rates permanently, spreading corrections across decades. Every timestamp needs metadata: “What rate was the clock running?”

DUT1 Dependency: Abandon synchronization entirely. UTC becomes pure atomic time. Systems needing Earth orientation must continuously process DUT1 broadcasts.

We spent fifty years teaching computers to pause for one second. Now we must teach them to forget.

“The software burden is staggering. Every system must maintain two time models: pre-2035 with leap seconds, post-2035 without.”

Sources and Further Reading

IERS Bulletin C Archives - Official leap second announcements

ITU-R TF.460-6 - Standard-frequency and time-signal emissions

POSIX.1-2017 Time - How Unix systems handle time

History of Leap Seconds - NIST's comprehensive FAQ

The leap second: its history and possible future - McCarthy & Seidelmann, Metrologia 2008

Linux Kernel Leap Second Bug Analysis - LWN.net deep dive

2012 Leap Second Incident Report - Cloudflare's analysis

Google's Time Smearing - Official documentation

Meta: It's Time to Leave the Leap Second in the Past

AWS Leap Second Handling

Resolution 4 of the 27th CGPM (2022) - The decision to end leap seconds

A Leap Second Proposal - Steve Allen's comprehensive resource


[ KEEP READING ]

Learn more

Explore more about how Greptile works


AI Code Review - Greptile | Merge 4X Faster, Catch 3X More Bugs