I have a method that returns the first day of the first week of a month, for making a little calendar:
def month_first_week_day(month, year)
start = DateTime.civil(year, month, 1)
start_date = DateTime.commercial(year, cweek, 1)
end
But I have this issue:
Date.civil(2011, 1, 1).cweek # => 52
I want it to return 1, not 52. I found this same problem in java here: Why does the en_GB locale think the 1st of January is the 52nd week of the year?.
Any suggestion?
You could use
Date.new(year, month).beginning_of_monthinstead of writing a function that does the same thing. See more hereAs an example
Edit: List of all the functions to do calculations on Date