class Date
def self.gregorian_leap?(y)
y % 4 == 0 && y % 100 != 0 || y % 400 == 0
end
end
class Time
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def self.days_in_month(month,year = now.year)
return 29 if month == 2 && ::Date.gregorian_leap?(year)
COMMON_YEAR_DAYS_IN_MONTH[month]
end
end
puts Time.days_in_month(2,2000)