Hey, there! I'm currently hiring for a Senior Mobile App Developer role at HarperCollins Christian Publishing. If you or someone you know is interested, please let me know via LinkedIn.
def days_in_month(year, month)
Date.new(year, 12, 31).prev_month(12 - month).day
end
You’re basically grabbing the last day of the year, and then getting the day for n months previous (12 - month).
Update: For those who ask, “Yeah, but how do you find the first day of the month?” It’s “1”.