rails/rails — pull request #3547 by gregolsen (2011-11-07 09:21:10+00:00)
Title: beginning_of_week and end_of_week extended to work with any week start

In rails week starts from Monday and there's no built-in way to get beginning of week, that starts from another day.
That's especially important for people in US, where week starts from Sunday. Also ruby considers Sunday as a week start.

Me and many others (http://bit.ly/v4H8RB, http://bit.ly/vclIEd) faced this problem, so I re-write beginning_of_week (and end_of_week) to take week start day symbol as an argument and return week start (end) based on that day. days_to_week_start method added (return number of days to week start) and it's used in both beginning_of_week and end_of_week.