diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-16 05:56:49 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-16 05:56:49 +0000 |
commit | a3659d583586d45c5f48fdd103ff8c797cecfafe (patch) | |
tree | 26bcbdffe69b82de8e5969c3ea48c15a6dc4adbe /activesupport/lib/active_support/core_ext/time/calculations.rb | |
parent | 4351419ba510be02b99215028807e8341c26428c (diff) | |
download | rails-a3659d583586d45c5f48fdd103ff8c797cecfafe.tar.gz rails-a3659d583586d45c5f48fdd103ff8c797cecfafe.tar.bz2 rails-a3659d583586d45c5f48fdd103ff8c797cecfafe.zip |
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
Diffstat (limited to 'activesupport/lib/active_support/core_ext/time/calculations.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 3 |
1 files changed, 2 insertions, 1 deletions
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 |