How can I in rails calculate the number of weeks in a given month?
Thanks
How can I in rails calculate the number of weeks in a given month?
Thanks
def number_of_weeks_month(start_of_month, count, end_of_month)
if start_date > end_of_month
return count
else
number_of_weeks_month(start_date.end_of_week + 1, count + 1, end_of_month)
end
end
get number of weeks for month like this
number_of_weeks_month(Date.parse("2017-11-01"),0,Date.parse("2017-11-30"))
this return 4