Given a date, how do I find the nearest Monday in Rails?
I know I can do things like:
Date.tomorrow Date.today
Is there something like Date.nearest :mond
I know this is an old thread but it's always nice to keep it current for future seekers.
Let's assume today is say Friday the 19th of August. All I do to get my nearest Monday is this:
monday = Date.today.monday
Then from there you can go back a week or forward a week like this:
last_monday = monday.last_week
next_monday = monday.next_week