What is a Leap Second and why is it worth your time?

Because of irregularities in the Earth's rate of rotation, time calculated using Earth's rotation drifts away from atomic time. Due to this, the International Earth Rotation and Reference Systems Service (IERS) introduced the concept of a leap second.

Because the Earth's rotation speed varies, UTC leap seconds are irregularly spaced and unpredictable. Insertion of each UTC leap second is usually decided about six months in advance by the IERS.

A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC). The IERS usually decides to apply a leap second whenever the difference between UTC and the mean solar time approaches 0.6 seconds.

A positive leap second is inserted between second 23:59:59 of a chosen UTC calendar date (the last day of a month, usually June 30 or December 31) and second 00:00:00 of the following date. This extra second is displayed on UTC clocks as 23:59:60.

Leap Second Clock

Unlike leap days, UTC leap seconds occur simultaneously worldwide (since it happens in UTC); for example, the leap second of December 31, 2016 23:59:60 UTC will be January 1, 2017 00:59:60 in Malta (Central European Time UTC +1) and January 1, 2017 08:59:60 in Japan (Japan Standard Time UTC +9) and December 31, 2016 18:59:60 in New York (Eastern Standard Time UTC -5).

2016's Leap Second

On 6th July 2016, the IERS announced that an extra second will be injected into UTC on December 31st 2016. This will be the 27th leap second introduced since this system of correction was implemented in 1972.

So, at the stroke of midnight UTC on New Year's Eve of 2016, an extra second will be introduced, effectively causing the last second of the day to last for two seconds. Time will advance from: 2016-12-31 23:59:58 UTC to 23:59:59 to 23:59:60 before reaching 2017-01-01 00:00:00 UTC.

IERS 2016 Leap Second Announcement

Why should you care?

One of the worst impacts of the Leap Second is that programmers and system administrators are oblivious to it. It's very important to understand how the leap second works and how it might affect your software, infrastructure and business.

Most clocks do not support a leap second; they physically cannot allow the 60th second to happen. This is not really that important for personal computers or mobile phones, but it is critical for time sensitive applications like medical equipment, databases, GPSes (air traffic control, missile guidance systems), nuclear reactors, ongoing experiments, synchronized replication, etc...

Many big sites have fallen victims to the leap second bug; sites like reddit, Yelp, FourSquare and LinkedIn.

Inevitably, there are a variety of clocks working in a single system at a given time; the worst thing being that they don't all act the same:

Handling a Leap Second

The three ways how to handle a leap second, in order of personal preference, are:

  1. Slew (smear) the leap second
  2. Step back the clock
    • This is the default approach in Windows and most other Operating Systems.
    • NTP Servers send out the Leap Indicator (LI) field which notify the Clock Services that a leap second will occur.
    • The NTP Client, then, will repeat the 59th second twice, thus resolving the time difference with UTC.
  3. Ignore the leap second
    • It is possible to ignore the leap second entirely. The clock will continue with the incorrect time until it is addressed through normal operation.