From a3659d583586d45c5f48fdd103ff8c797cecfafe Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 16 Jun 2005 05:56:49 +0000 Subject: Fixed Time#at_beginning_of_week returned the next Monday instead of the previous one when called on a Sunday #1403 [jean.helou@gmail.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1431 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/time/calculations.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 1c9a3523a9..8247003ca3 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -87,7 +87,8 @@ module ActiveSupport #:nodoc: # Returns a new Time representing the "start" of this week (Monday, 0:00) def beginning_of_week - (self - self.wday.days).midnight + 1.day + days_to_monday = self.wday!=0 ? self.wday-1 : 6 + (self - days_to_monday.days).midnight end alias :monday :beginning_of_week alias :at_beginning_of_week :beginning_of_week -- cgit v1.2.3