Wow, I didn't know that was there. ARGH.
I guess I can throw this messy thing out:
public static int GetDaysInMonth(int month, int year)
{
if (month < 1 || month > 12)
{
throw new System.ArgumentOutOfRangeException("month", month, "month must
be between 1 and 12");
}
if (1 == month || 3 == month || 5 == month || 7 == month || 8 == month ||
10 == month || 12 == month)
{
return 31;
}
else if (2 == month)
{
// Check for leap year
if (0 == (year % 4))
{
// If date is divisible by 400, it's a leap year.
// Otherwise, if it's divisible by 100 it's not.
if (0 == (year % 400))
{
return 29;
}
else if (0 == (year % 100))
{
return 28;
}
// Divisible by 4 but not by 100 or 400
// so it leaps
return 29;
}
// Not a leap year
return 28;
}
return 30;
}
Pete