Methods
Public Instance methods
Return the number of days in the given month. If a year is given, February will return the correct number of days for leap years. Otherwise, this method will always report February as having 28 days.
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 15 15: def days_in_month(month, year=nil) 16: if month == 2 17: !year.nil? && (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) ? 29 : 28 18: elsif month <= 7 19: month % 2 == 0 ? 30 : 31 20: else 21: month % 2 == 0 ? 31 : 30 22: end 23: end