app/helpers/calendar_helper.rb in kit_cms-2.3.20 vs app/helpers/calendar_helper.rb in kit_cms-2.3.22

- old
+ new

@@ -127,10 +127,11 @@ return "[can't find calendar '#{calendar_id}']" unless cal entries = {} days_in_this_month = days_in_month(month) + logger.debug "**** days in month #{month} #{days_in_this_month}" for i in 1..days_in_this_month do entries[i] = [] end start_date = date end_date = Time.new(year,month,days_in_this_month, 23, 59, 0, 0) @@ -158,11 +159,14 @@ logger.debug e.backtrace.join('\n') return "[cannot display calendar]" end end - def days_in_month(d) - (Date.new(d.year, 12, 31) << (12-d.month)).day + COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + + def days_in_month(month, year = Time.now.year) + return 29 if month == 2 && Date.gregorian_leap?(year) + COMMON_YEAR_DAYS_IN_MONTH[month] end def regions_list last_region_id = nil first = true