Possible Duplicate:
how to find leap year?
What will be the exact definition of leap year? AFAIK "A year which is divisible by 4 is a leap year. But for century years' the years which are divisible by 400 is a leap year."
But that definition makes 100, 200, 300, 400.... upto 1700 NOT LEAP years! But in Gregorian calendar all of them are all leap year, check this out.
You can also try "call 1700" in Linux to verify.
So the correct algorithm for leap years would be:
if ( (year % 4 == 0) && ( year <= 1700 || year % 100 != 0 || year % 400 == 0 ))
printf("%d is a leap year.\n", year);
else
printf("%d is not a leap year.\n", year);
But is this specific to Gregorian calendar? Even if that is the case why is it not mentioned here?
Regards,
PS:The history of Gregorian callender seems interesting check out the September month of 1752.
I think it's important to separate the idea of historical dates on the one hand and date calculation on the other. Historical dates are subject to all kinds of political, social, and technological issues, and are thus not very suitable for a simple algorithm. See this page for the wide disparity in the adoption of the modern Gregorian calendar.
The usual practice when calculating dates is to forget about history and just pretend that the existing system has always been in place and will always be in place. (Unless you are an astronomer or certain other kinds of scientist, in which case you would use something even more accurate, and would be even less interested in historical dates.) If your application is all about recorded historical dates, then you are going to need a way to map those dates (which depend on the country, the period in history, etc.) to a more calculation-friendly universal dating system anyway.