by throw0101c · 2y ago · 0 comments
"Everyone" knows that leap years occur on year divisible by 4 ('first rule'). The second rule to them is that if a year is divisible by 100 (1800, 1900, …2000), then it is not a leap year.
So a lot of folks did not have their systems/software have February 29 in the year 2000.
But there is a third rule: if the year is divisible by 400 (like 1600… and 2000) it is a leap year.
* https://en.wikipedia.org/wiki/Leap_year#Gregorian_calendar
* https://en.wikipedia.org/wiki/Gregorian_calendar#Accuracy
Lots of folks missed the 'third rule'. Hilarity ensued.
* https://en.wikipedia.org/wiki/Year_2000_problem#On_29_Februa...
Actually, I think that's the only rule most people know. I think the "funny story" is actually the opposite: most people were treating 2000 as an ordinary every-4-year leap year, did not know about the 100 divisor, but were inadvertently saved by the 400 divisor.
The Wikipedia link does document some cases of what you say (yes on the 2nd rule, omitting the 3rd rule) but I think there were far, far more cases of simply assuming only the 1st rule applied.
Instead of showing rules as a linear list, I'd suggest it's easier to visualise it as a tree, or simpler still, as a series of nested ifs.
Best to describe it as a flowchart
* Is the year divisible by 400? YES -> Leap year
* NO -> Is the year divisible by 100? YES -> Not leap year
* NO -> Is the year divisible by 4? YES -> Leap year
* NO -> Not leap year
* Is the year divisible by 4? NO -> not leap year
* YES -> Is the year divisible by 100? NO -> leap year
* YES -> Is the year divisible by 400? NO -> not leap year
* YES -> leap year
This way you do only 1 division for 75% of years.
Feel free to post a comment with ASCII art or (pseudo-)code. :)
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
[it's a leap year]
else
[it's not]
I remember this because it is where I first learned the extra rules, beyond just every 4th year.https://en.wikisource.org/wiki/Translation:Inter_gravissimas
"Next, so that the equinox will no longer recede in future from the twelfth day before the Kalends of April [i.e. 21 March], we decree:
that the bissextile day every fourth year shall continue, as the custom is now, except in centurial years, although these were always bissextiles before, and we wish the year 1600 to be bissextile as well;
after that, however, the centurial years that follow shall not all be bissextiles, only every fourth centurial year shall be bissextile, thus the years 1700, 1800 and 1900 shall not be bissextile. But in the year 2000, the bissextile day shall be added in the usual way, with February containing 29 days;
and then the same order of leaving out and adding the bissextile day shall be observed in each period of 400 years ever after."LOL.