As the Earth travels around the Sun, it spins once per day, and the axis of this spin precesses. When the plane of the Earth's equator sweeps past the Sun going from North to South, this is called the Vernal Equinox. It marks the begining of Spring in the Northern Hemisphere. This occurs once every time the Earth rotates 365.242191 times. So, the length of this "tropical year" is 365.242191 days.

Each year on our calendar must contain an integer number of days. By holding a February 29 every once in a while (during a "leap year"), we can change the average length of the year over the long run. If we make the average length of the year equal to a tropical year, then the seasons won't "slip" over time, causing farmers to have to plant their crops at increasingly different times of year.

The rules are, in order of increasing priority:

1) If the year is divisible by 4, then it is a leap year. (add 1/4)

2) If the year is also divisible by 100, then it is not a leap year. (subtract 1/100)

3) If the year is also divisible by 400, then it is a leap year. (add 1/400)

4*) If the year is also divisible by 3200, then it is not a leap year. (subtract 1/3200)

So the average length of the year is:

365 + 1/4 - 1/100 + 1/400 - 1/3200 = 365.2421875

The difference between this and the tropical year is 0.0000035 days, or 0.3 seconds. So, with these rules, as the eons pass by the seasons will shift by 0.3 seconds per year, adding up to a day per 286,000 years. This difference should not annoy farmers for a long time! Also, on a more practical level, this may never really be important, since the Earth does not rotate at a uniform rate (due to tidal friction, continental drift, etc.). This is kept track of by "leap seconds", which keep the sun over Greenwich at noon. If the length of the day varies significantly over the next few 100,000 years (it will certainly lengthen slightly, as the Earth transfers its angular momentum to the Moon by tidal friction), this will change the number of days in a tropical year, and we will have to change the "Rules" accordingly.

Examples:

2005: Not divisible by 4, therefore, no Feb 29, 2005. (The same applies to 2006, 2007, 2009, etc.)

2004: Divisible by 4, therefore by rule #1, there was Feb 29, 2004. (The same applies for the year 2008, 2012, 2016, etc.)

1900: Divisible by 4, BUT, also divisible by 100, therefore by rule #2, no Feb. 29, 1900. (The same applies to the year 2100, 2200 and 2300.)

2000: Divisible by 4, BUT, also divisible by 100, BUT, also divisible by 400, therefore, by rule #3, there was Feb 29, 2000. (The same applies to the year 2400.)

3200: Divisible by 4, BUT, also divisible by 100, BUT, also divisible by 400, BUT, also divisible by 3200, therefore by rule #4, there will be no Feb 29, 3200.

* Note - In fact, I made up Rule #4 myself. But if I'm around in the Year 3200, I am going to recommend to the local authorities that it not be a leap year. And I suppose I'll have to present the same kind of arguments in 6400, so I should keep my notes.