aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-19 17:36:25 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-19 17:36:25 +0000
commitf9103e1fe20e66315f4ea73e14df8850eec2f8e3 (patch)
tree47b46f0a3a623d7c9331d38e569c6210546141cd
parent26022d8d2acedca2a7b637fde698785d0c4fee79 (diff)
downloadrails-f9103e1fe20e66315f4ea73e14df8850eec2f8e3.tar.gz
rails-f9103e1fe20e66315f4ea73e14df8850eec2f8e3.tar.bz2
rails-f9103e1fe20e66315f4ea73e14df8850eec2f8e3.zip
Fixed Time#last_year to go back in time, not forward #1278 [fabien@odilat.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1319 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb6
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb4
3 files changed, 9 insertions, 3 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index ee8afe427e..cc0bdf6586 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed Time#last_year to go back in time, not forward #1278 [fabien@odilat.com]
+
* Fixed the pluralization of analysis to analyses #1295 [seattle@rootimage.msu.edu]
* Fixed that Time.local(2005,12).months_since(1) would raise "ArgumentError: argument out of range" #1311 [jhahn@niveon.com]
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index f238ca168a..1c9a3523a9 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -64,12 +64,12 @@ module ActiveSupport #:nodoc:
change(:year => self.year + years)
end
- # Short-hand for months_ago(1)
+ # Short-hand for years_ago(1)
def last_year
- years_since(1)
+ years_ago(1)
end
- # Short-hand for months_since(1)
+ # Short-hand for years_since(1)
def next_year
years_since(1)
end
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 6bad622386..18ae3219bc 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -56,6 +56,10 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
# Failure because of size limitations of numeric?
# assert_equal Time.local(2182,6,5,10), Time.local(2005,6,5,10,0,0).years_since(177)
end
+
+ def test_last_year
+ assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).last_year
+ end
def test_ago