Module ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods
In: vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb

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.

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 16
16:           def days_in_month(month, year=nil)
17:             if month == 2
18:               !year.nil? && (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) ?  29 : 28
19:             elsif month <= 7
20:               month % 2 == 0 ? 30 : 31
21:             else
22:               month % 2 == 0 ? 31 : 30
23:             end
24:           end

[Validate]