aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-24 00:07:01 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-24 00:07:01 +0000
commit5d94fb33c6b862c6b206c55f0d19e3f307fa4056 (patch)
tree60c9f6521d5e8fb718b7c8489a88dfe314c1ff8c /activesupport/test/core_ext/time_ext_test.rb
parent32dbf0b72554a9c32074a3f86ac1eabdbe6fbb5b (diff)
downloadrails-5d94fb33c6b862c6b206c55f0d19e3f307fa4056.tar.gz
rails-5d94fb33c6b862c6b206c55f0d19e3f307fa4056.tar.bz2
rails-5d94fb33c6b862c6b206c55f0d19e3f307fa4056.zip
Added year-based time calculations
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@779 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 5bdabb387e..7ae2062387 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -22,6 +22,10 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
def test_beginning_of_month
assert_equal Time.local(2005,2,1,0,0,0), Time.local(2005,2,22,10,10,10).beginning_of_month
end
+
+ def test_beginning_of_year
+ assert_equal Time.local(2005,1,1,0,0,0), Time.local(2005,2,22,10,10,10).beginning_of_year
+ end
def test_months_ago
assert_equal Time.local(2005,5,5,10), Time.local(2005,6,5,10,0,0).months_ago(1)
@@ -38,6 +42,19 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).months_since(12)
assert_equal Time.local(2007,6,5,10), Time.local(2005,6,5,10,0,0).months_since(24)
end
+
+ def test_years_ago
+ assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).years_ago(1)
+ assert_equal Time.local(1998,6,5,10), Time.local(2005,6,5,10,0,0).years_ago(7)
+ end
+
+ def test_years_since
+ assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).years_since(1)
+ assert_equal Time.local(2012,6,5,10), Time.local(2005,6,5,10,0,0).years_since(7)
+ # 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_ago
assert_equal Time.local(2005,2,22,10,10,9), Time.local(2005,2,22,10,10,10).ago(1)