Module: Holidays::CoreExtensions::Time::ClassMethods

Defined in:
lib/holidays/core_extensions/time.rb

Constant Summary collapse

COMMON_YEAR_DAYS_IN_MONTH =
[nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

Instance Method Summary collapse

Instance Method Details

#days_in_month(month, year = current.year) ⇒ Object

Returns the number of days in the given month. If no year is specified, it will use the current year.



13
14
15
16
17
18
19
# File 'lib/holidays/core_extensions/time.rb', line 13

def days_in_month(month, year = current.year)
  if month == 2 && ::Date.gregorian_leap?(year)
    29
  else
    COMMON_YEAR_DAYS_IN_MONTH[month]
  end
end