Date Trivia
Posted in 1993
For anyone interested, I typed in one of the date routines kindly provided to me by Cathy Kipp, so I could satisfy my curiousity about just what the rule for leap years is. I ran a quick program that calculated which years are _really_ leap years, and I compared that to the (year%4 == 0) rule and printed out the exceptions. Here are the results: 1700 is _not_ a leap year 1800 is _not_ a leap year 1900 is _not_ a leap year 2100 is _not_ a leap year 2200 is _not_ a leap year 2300 is _not_ a leap year 2500 is _not_ a leap year 2600 is _not_ a leap year 2700 is _not_ a leap year 2900 is _not_ a leap year Now with hindsight I remember the "real" rule that I learned while studying Astronomy: All years evenly divisible by four are leap years, except for years evenly divisible by 100 and not by 400. It doesn't say so in the article, but according to the results I got by applying the algorithm those exceptions do _not_ apply for years before 1700 (well, I only checked 600 to 1700). This makes sense, because 1582 is the "magic" year when there was no Oct. 5th through 14th, due to switching from the Julian calendar to the Gregorian calendar. I only ran my program to 2900 because the algorithm in the article says it's only valid to 2900. By the way, the "cal" program in Unix (SCO) gets this right, but in a funny way: cal gives dates for England and her colonies. According to the "cal" man page, England switched from Julian to Gregorian in 1752, so England didn't have a 9/3/1752 through 9/13/1752. I'm guessing that when the article said 1582, it was talking about Rome. Soooooo... Does anyone have a 4gl algorithm to convert a datetime years-to-microseconds interval to seconds, taking into account leap years and the change from the Julian to the Gregorian calendar? :-) -- Bill Foote bill@pds.com PDS Corp, Los Angeles, CA USA uunet!promdist!bill