Methods
D
Instance Public methods
days_in_month(month, year=nil)

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.

# File rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 15
def days_in_month(month, year=nil)
  if month == 2
    !year.nil? && (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) ?  29 : 28
  elsif month <= 7
    month % 2 == 0 ? 30 : 31
  else
    month % 2 == 0 ? 31 : 30
  end
end