Here's a little something that's useful. Just give me some credit for putting it together. Syntax is in Java, but it should be translatable to your favorite language.
Given the month number, m [1, 12], and the 4-digit year, this calculates the days of the month.
return m != 2 ? (((m < 8 && m % 2 != 0) || (m > 7 && m % 2 == 0)) ? 31 : 30) : (!(year % 400 == 0 || year % 100 != 0 && year % 4 == 0) ? 28 : 29);