The AlgorithmicRule for Leap Years and Leap Seconds
In order to keep our Gregorian calendar in sync with mean solar time (UT1 time scale), we need to add a second once in a while in addition to adding a day every four years. However, there is more complexity that needs to be considered.
As a Computer Systems Programmer I once had to write an algorithm to determine the day of the week (Monday, Tuesday, etc) for any specific calendar day. This required a thorough understanding of how the days of our calendar are calculated. So, I can explain it to you.
Extremely Accurate Time Measurements
We live in a time when we have the resources to do extremely accurate measurements. We have the technology to measure the rotation of the Earth so precisely that we can detect how it is slowing down. We use atomic clocks to keep an accurate account of time.
There are National Standards Agencies in many countries that maintain a network of atomic clocks. They are kept synchronized with extreme accuracy.
In addition, we have the master atomic clock at the U.S. Naval Observatory in Washington providing the time standard for the U.S. Department of Defense.
Managing The Extra Fractions of Days
If it takes exactly 365 days for the Earth to revolve around the Sun, then we would have a perfect calendar and there would be no need to make corrections.
If a year were exactly 365 and a quarter days, then adding a day every four years would work wonderfully too. Unfortunately our Earth goes around the sun in 365.2426 days, so adding a day every four years is adding too much.
We add an extra day, February 29th, every four years. However, we need to skip that addition once in a while.
I'll get a little deeper into the math to explain the details. If that additional fraction over 365 days were exactly .25 (an extra quarter of a day) then every four years adds up to a full day. If that were accurate, we would just add that extra day at the end of February every four years, but we don't. We need to skip some Leap Years.
That fraction I mentioned before, 0.2426, is a little less than a quarter of a day. Therefore, every 100 years we need to skip the addition of a day in February—otherwise we would be adding too much.
But wait! That still isn’t perfect!
Adjustments to Leap Years
We Need to Skip a Leap Year Every 100 Years
Skipping a leap year every 100 years only works if the extra time were exactly 0.25. However, we are still off by almost .01 from a quarter day. That .01 adds up to 1 in 100 years. Therefore we need to skip a leap year every 100 years. If we didn't skip it, we'd be adding too may days to the calendar.
We'll still get out of sync with solar time if we don't take it a step further.
As you can see, we still have that extra .0026 that we are off when skipping a leap year every 100 years. If you add that up, with some rounding error, that .0026 is a little over 1 day every 400 years (.0026 x 400 = 1.04) .
That means that skipping a leap year every 100 years needs adjustment as well. We need to add a day back in.
We Need to Add an Extra Day Every 400 Years
Remember that I said we normally skip a leap year every 100 years? However, we need to keep that leap year every 400 years in order to get that one extra day added back in.
The easiest way to add that missing day back in is to not skip a leap year if the year is a multiple of 400, even though it is also a multiple of 100. In other words, we keep February 29th on the calendar every 400 years.
In Summary
Just to say it all in one sentence: We add a day every four years, but not every 100 years, unless it’s a 4th century year, at which point we do add that extra day anyway.
Table of Leap Years and the Reasons For It
Year
 Leap Year if Multiple of 4
 But Skip if Multiple of 100
 Unless it's a Multiple of 400
 Leap Year?


1600
 Yes
 
 Yes
 Yes

1700
 Yes
 Yes
 No
 No

1800
 Yes
 Yes
 No
 No

1900
 Yes
 Yes
 No
 No

2000
 Yes
 
 Yes
 Yes

2004
 Yes
 No
 
 Yes

2008
 Yes
 No
 
 Yes

2012
 Yes
 No
 
 Yes

2016
 Yes
 No
 
 Yes

2100
 Yes
 Yes
 No
 No

Leap Seconds
Why We Need to Add Seconds to Our Calendar
The algorithm for leap years still does not provide perfect accuracy. Adding a few seconds is also required. Climate and geological events can cause the Earth’s revolution around the Sun to fluctuate.
In addition to that, the Earth's rotation around its own axis is not consistent. It tends to slow down and speed up ever so little.
It has been reported that the 9.0 magnitude Earthquake in Japan in 2011 had shifted the Earth's axis by an amount between 10 cm (4 inches) and 25 cm (10 inches). Fluctuations such as this change the length of a day by an eversotiny amount and it needs to be adjusted on our calendar.^{1 }
In order to improve the accuracy of our time clocks, we need to add a second or two every year. It’s called a leap second.^{2 }
Scheduling the addition of an extra second to a year is done to make these adjustments.
It's usually added, when needed, as an additional second at midnight, Coordinated Universal Time (UTC), on June 30th or December 31st.
International Earth Rotation and Reference Systems Service
Recent Time Adjustments
The International Earth Rotation and Reference Systems Service is the agency that decides when these time adjustments are made. They apply a leap second whenever necessary to keep our clock from being more than 0.9 of a second off.
Here is a recent table of dates that a second is added at midnight (UTC):
 December 31, 2008
 December 31, 2005
 June 30, 2012
 June 30, 2015
 December 31, 2016
 June 30, 2018
Physical events, such as earthquakes, can nudge the Earth just enough to require adding another leap second so that our clocks remain in sync with the way we represent time. It's an ongoing struggle to keep this as accurate as possible, but with the present technology, we have the means to do it.
Questions & Answers
© 2012 Glenn Stok
3