house9

random code and what not

Get the date of the beginning and end of a month using Ruby

Sometimes Ruby blows my mind, I needed to get the start date and end date of the previous month. Guess what Ruby just happens to have methods to handle this - beginning_of_month, end_of_month, there is even beginning_of_quarter and end_of_quarter if you need them!