On December 31st, 2016 the day will be a full second longer than a normal day, instead of there being 86400 seconds in the day, there will be 86401 seconds. That's weird right? time is supposed to be this consistent thing. There are always 60 seconds in a minute, always 60 minutes in an hour, and always 24 hours a day. so their should always be 86,4001 seconds in a day.

So if that's the case, then why does the 31st of December, 2016 have an extra second?
The answer has to do with the rotation of our favourite celestial body around the sun. But before we get to that, I'll fill you in on some of the background.

How long is a second?

It's an odd question, a bit like asking "how long is a piece of string?"

The answer lies in how we measure seconds. In 1900 a second was defined in terms of the period of the Earth's orbit around the sun, we had agreed on the number of days in a year, and knew that we wanted 24 hours in a day, 60 minutes in an hour, and 60 seconds in a minute. So in 1900 we defined the second as being \(1 \over 31,556,925.9747\) of the year2. Since then we've developed the International System of Units (SI), which is an attempt to define various measurements using universal constants (that way they're not dependent on an object or a location, so we can record time even when we're not on the earth). The SI currently defines a second as:

The second is the duration of 9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the cesium 133 atom.

What this means is that the second is considered to be about 9 billion vibrations from a cesium 133 atom. The "ground state" part means that the atom needs to be at rest (for earth, that means sea level), and 0 degrees kelvin. It's a very large, weird number because we've worked backwards to get it. We knew how long we wanted a second to be, we just needed to find some way to express it that didn't require anything specific to our environment.

Where do extra seconds come from?

Now the reason we have an extra second is because scientists use something called an Atomic Clock, to measure time. An atomic clock uses the SI definition of a second to measure time, which gives them an extremely accurate measurement. However, the downside is that the accuracy of the atomic clock no longer matches the original definition of a second, the one based on the earth's rotation of the sun.

"why don't they just adjust the definition of a second then? just knock off a few thousand vibrations!" I hear you say. The issue isn't the length of the second, so much as it is the speed at which the earth rotates the sun. As it happens, the earth doesn't rotate the sun at a consistent speed, and lately it's been slowing down by about 1 seconds every few years. The result is that in order to keep our atomic clocks from getting out of sync with earth time, we have to occasionally add a second on to the end of the day.

Generally, the seconds are added either at the end of June, or at the end of December, but this isn't a hard rule. The International Earth Rotation and Reference Systems Service (IERS) group usually announce coming leap seconds giving around 6 months notice for the impending adjustment.

Cool, but why do I care?

That's all a bit interesting, but the final question you're probably wondering about is "Why does this matter?"
The answer to which is that lots of computer systems make assumptions about the behaviour of time. Assumptions that are often wrong when it comes to the inclusion of leap seconds.

The problems arise from how the extra second is handled, with different systems applying different solutions to how they add the extra second, all of which having potential downsides.

For example, some systems repeat the last second of the day so that 23:59:59 occurs twice, however this can causes issues with databases (where time is recorded to the millisecond and expected to be unique, if the same second occurs twice a timestamp collision could occur), it's also possible for this solution to create vulnerabilities in security systems that rely on random numbers (as random is often seeded from the current time, duplicating the time weakens the security).

Other systems like Google, make tiny adjustments throughout the day so that the time at the end of the day is correct, this avoids issues caused by collisions (which is highly likely to occur at Googles scale), but the downside of this approach is that the time is off by an increasing amount throughout the day, which can cause issues when interacting with systems that don't adjust the time in this manner.

The final and recommended approach to handling the extra second is to just add an extra second after 23:59:59 so that the next tick is 23:59:60, instead of 00:00:00. This avoids issues with timestamp collisions and any issues that might occur from having the time just be wrong for the entire day. The problem with this solution is that next to no software makes allowances for a 61st second (because it's so rare), and as a result much of it either crashes or encounters undefined behaviour (which just means nobody know's what it's going to do).

This probably all sounds like posturing, but in 2012 the addition of a leap second caused both Qantas' and Reddit to crash.


  1. \(60 \times 60 \times 24 = 86,400\)  

  2. \(year = 365.242 \times 86,400 \)