I\'m sure there\'s a good simple elegant one-liner in Ruby to give you the number of days in a given month, accounting for year, such as \"February 1997\". What is it?
This is the implementation from ActiveSupport (a little adapted):
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def days_in_month(month, year = Time.now.year) return 29 if month == 2 && Date.gregorian_leap?(year) COMMON_YEAR_DAYS_IN_MONTH[month] end