Every now and then I find someone that still believes leap days come in 4 year cycles, no exception made. Some of them are even programmers that never had to implement a leap year algorithm:
public static class DateUtils
{
public static bool IsLeapYear(this int year)
{
return (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0));
}
}
I used to get quite nervous with the fact, but not anymore. Why? This just doesn’t impact on today’s every days life :) Let me try and prove it to you:
foreach (
var year in
Enumerable.Range(1582, 1500)
.Where(d => (d % 4 == 0) && d.IsLeapYear() == false)
)
{
Console.WriteLine("{0}", year);
}
So what am I getting? On the first 1500 years since the Gregorian calendar as defined the present algorithm, which of these 4 year cycles weren’t leap years?
Oops, it seems like no one I know was born of probably be alive on those days, who cares? “Press any key to continue”: yeap, seems right :)
No comments:
Post a Comment