public static bool IsLeapYear(DateTime date)Check for it this way:
{
int year = date.Year;
if (year % 400 == 0)
return true;
else if (year % 100 == 0)
return false;
else if (year % 4 == 0)
return true;
else
return false;
}
public static int DaysInYear(DateTime date)
{
return IsLeapYear(date) ? 366 : 365;
}
No comments:
Post a Comment