I have a Date object
Mon, 03 Dec 2012
and I have a String that contains a day name
"Thursday"
How can I use those two objects to find a new Date object representing the day name in the same week as the original Date object? So for this example, it would be
Thu, 07 Dec 2012
In this scenario, a week goes from Monday to Sunday.
I’m using Rails 3.2.0 and Ruby 1.9.3.
If you can manage to convert “Thursday” to week day 4 — I know you can –, you can get another date like this:
BTW, you can store the map from day name to number in an Array or an Hash, or use I18n.