12,445,931 members (68,964 online)
alternative version

91.8K views
37 bookmarked
Posted

# Leap Years

, 20 Feb 2000 CPOL
 Rate this:
A discussion on the thorny issue of leap years.

There has been a lot of interest about the correct method of calculating leap years lately, especially since it seems many programmers have got it wrong. Before Y2K the approximation "a leap year occurs every four years" was good enough for most situations. If you needed to deal with historical dates (post 1600AD), then you had to add the clause "unless the year was divisible by 100".

This is where many programmers left it - but the rule for the Gregorian calendar is:

1. Most years divisible by 4 are Leap Years (i.e. 1996 was)
2. However, most years divisible by 100 are NOT! (1900 was not)
3. Unless they are also divisible by 400 (2000 will be)

It turns out though that there are even more subclauses that can be appended to these rules to take into account the fact that the Earth takes 365.2421898 days to orbit the sun (well, it did in 1996 - it's now a shade shorter than that). Because of this, the Gregorian calendar will be off by about a day in 3000 years or so. There are various proposals on how to deal with this, but it seems it won't really be an issue until 2800AD.

One proposal (by the astronomer John Herschel (1792-1871) among others) suggests

• Every year which is divisible by 4000 is not a leap year.

This is more accurate than the Gregorian calendar, but has not been officially adopted.

Another proposal (by the Orthodox church in Greece) is to replace the "divisible by 400" rule by the following:

• Every year which when divided by 900 leaves a remainder of 200 or 600 is a leap year.

This makes 1900, 2100, 2200, 2300, 2500, 2600, 2700, 2800 non-leap years, whereas 2000, 2400, and 2900 are leap years. This will not create a conflict with the rest of the world until the year 2800. However, this rule has also not been officially adopted.

## Share

Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.

His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.

He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.

Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.

 United States
No Biography provided

## You may also be interested in...

 Pro Pro

 First Prev Next
 My vote of 5 CIDev24-Sep-10 6:18 CIDev 24-Sep-10 6:18
 Orthodox Church m00n120-Jul-10 3:51 m00n1 20-Jul-10 3:51
 Oops! Chris Hills2-May-05 6:39 Chris Hills 2-May-05 6:39
 Re: Oops! Chris Maunder10-Jul-07 2:48 Chris Maunder 10-Jul-07 2:48
 Has anyone seen gmttime() ? Bamaco229-Jan-04 8:10 Bamaco2 29-Jan-04 8:10
 ...in other words dixi16-Jul-00 12:04 dixi 16-Jul-00 12:04
 Re: ...in other words wulph10-Dec-03 13:56 wulph 10-Dec-03 13:56
 History Michael Krebs25-Feb-00 12:45 Michael Krebs 25-Feb-00 12:45
 Last Visit: 31-Dec-99 18:00     Last Update: 24-Aug-16 6:07 Refresh 1