Last updated 1998 June 24 Roedy Green ©1996-1998 Canadian Mind Products.
Stuck in a frame? Click here to break out.Julius Caesar created the modern calendar in 46 BC. Prior to that it was a mess well beyond your wildest dreams. The Julian calendar is still used by the Russian Orthodox church and by programmers who are ignorant of the official Gregorian calendar. It has leap years every four years without exception. It corrects to 365.25. It gets ahead 1 day every 128 years.
public static final boolean isLeapViaJulian (int yyyy) { return yyyy % 4 == 0; }
Joseph Justus Scaliger (1540-1609) invented an Astronomical Julian calendar, (named after his father Julius Caesar Scaliger). This Julian calendar uses the offset in days since noon, Jan 1st 4713 BC. In that scheme, 2000 January 1 noon is the start of day number 2,451,545. This calendar follows the original Julian scheme of always adding leap years every four years.
The next major correction was the Gregorian calendar. By 1582, this excess of leap years had built up noticeably. At the suggestion of astronomers Luigi Lilio and Chistopher Clavius, Pope Gregory XIII dropped 10 days from the calendar. Thursday 1582 October 4 Julian was followed immediately by Friday 1582 October 15 Gregorian. He decreed that every 100 years, a leap year should be dropped except that every 400 years the leap year should be restored. Only Italy, Poland, Portugual and Spain went along with the new calendar immediately. One by one other countries adopted it in different years. Britain and its territories (including the USA and Canada) adopted it in 1752. By then, 11 days had to be dropped. 1752 September 2 was followed immediately by 1752 September 14. The Gregorian calendar is the most widely used scheme. This is the scheme endorsed by the US Naval observatory. It corrects the year to 365.2425. It gets ahead 1 day every 3289 years.
public static final boolean isLeapViaPopeGregory (int yyyy) { if ( yyyy < 1582 ) return yyyy % 4 == 0; if ( yyyy % 4 != 0 ) return false; if ( yyyy % 100 != 0 ) return true; if ( yyyy % 400 != 0 ) return false; return true; }
Astronomer John Herschel (1792-1871) suggested dropping a leap year every 4000 years. This scheme never received official support. It corrects to 365.24225. It gets ahead 1 day every 18,519 years.
public static final boolean isLeapViaHerschel (int yyyy) { if ( yyyy < 1582 ) return yyyy % 4 == 0; if ( yyyy % 4 != 0 ) return false; if ( yyyy % 100 != 0 ) return true; if ( yyyy % 400 != 0 ) return false; if ( yyyy % 4000 != 0 ) return true; return false; }
The Greek Orthodox church drops the 400 rule and in its place uses a rule that any year that when divided by 900 gives a remainder of either 200 or 600 is a leap year. This is the official system in Russia. It corrects to 365.24222. It gets ahead 1 day every 41,667 years.
public static final boolean isLeapViaGreek (int yyyy) { if ( yyyy < 1582 ) return yyyy % 4 == 0; if ( yyyy % 4 != 0 ) return false; if ( yyyy % 100 != 0 ) return true; int remdr = yyyy % 900; return remdr == 200 || remdr == 600; }
The SPAWAR group in the US Navy propose the following algorithm where a leap year is dropped every 3200 years. This is most accurate of the schemes, and also has the desirable property of undercorrecting, leaving room for leap second correction. It corrects to 365.2421875. It gets behind 1 day every 117,647 years. Leap seconds are added on average every 3 out of 4 years to correct for the ever lengthening day. This means it is best to have a scheme with slightly too few leap days than too many, since the leap seconds can compensate also. Leaps second add up to roughly an extra day every 115,000 years. When you consider the effects of leap seconds, this scheme is bang on, within the limits of the varying length of an astronomical year.
public static final boolean isLeapViaSPAWAR (int yyyy) { if ( yyyy < 1582 ) return yyyy % 4 == 0; if ( yyyy % 4 != 0 ) return false; if ( yyyy % 100 != 0 ) return true; if ( yyyy % 400 != 0 ) return false; if ( yyyy % 3200 != 0 ) return true; return false; }
I will leave as an exercise for the reader the staircase leap year algorithm that is the most accurate possible. If you get it, I will post it here with an attribution to you. Hints:
year | Julian Leap? | Gregorian Leap? | Herschel Leap? | Greek Leap? | SPAWAR Leap? |
---|---|---|---|---|---|
1 | no | no | no | no | no |
4 | yes | yes | yes | yes | yes |
1580 | yes | yes | yes | yes | yes |
1582 | no | no | no | no | no |
1584 | yes | yes | yes | yes | yes |
1600 | yes | yes | yes | no | yes |
1700 | yes | no | no | no | no |
1800 | yes | no | no | no | no |
1900 | yes | no | no | no | no |
1996 | yes | yes | yes | yes | yes |
1997 | no | no | no | no | no |
1999 | no | no | no | no | no |
2000 | yes | yes | yes | yes | yes |
2100 | yes | no | no | no | no |
2200 | yes | no | no | no | no |
2300 | yes | no | no | no | no |
2400 | yes | yes | yes | yes | yes |
2800 | yes | yes | yes | no | yes |
2900 | yes | no | no | yes | no |
3200 | yes | yes | yes | no | no |
3300 | yes | no | no | yes | no |
3600 | yes | yes | yes | no | yes |
3800 | yes | no | no | yes | no |
4000 | yes | yes | no | no | yes |
4200 | yes | no | no | yes | no |
4400 | yes | yes | yes | no | yes |
4700 | yes | no | no | yes | no |
4800 | yes | yes | yes | no | yes |
5100 | yes | no | no | yes | no |
5200 | yes | yes | yes | no | yes |
6400 | yes | yes | yes | no | no |
6500 | yes | no | no | yes | no |
6800 | yes | yes | yes | no | yes |
6900 | yes | no | no | yes | no |
7200 | yes | yes | yes | no | yes |
7400 | yes | no | no | yes | no |
7600 | yes | yes | yes | no | yes |
7800 | yes | no | no | yes | no |
![]() |
![]() |
Click to download the latest browser software. |
![]() |
![]() |
![]() |
|
Canadian Mind Products | The Mining Company's Focus on Java Best of the Net Award |
You can get an updated copy of this page from http://mindprod.com/jglossl.html |