diff options
author | Jamis Buck <jamis@37signals.com> | 2005-08-31 10:36:35 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-08-31 10:36:35 +0000 |
commit | 70e96c9f5c1bfcbb056c34fe7afe3d39226d1cc6 (patch) | |
tree | f268a0a5b9527e25b44412019da8b79756e6ce97 /activesupport/test/core_ext | |
parent | 2a8e33872b3b8f297cad50a2c5eaba3cbaeeaa1b (diff) | |
download | rails-70e96c9f5c1bfcbb056c34fe7afe3d39226d1cc6.tar.gz rails-70e96c9f5c1bfcbb056c34fe7afe3d39226d1cc6.tar.bz2 rails-70e96c9f5c1bfcbb056c34fe7afe3d39226d1cc6.zip |
Add Time.days_in_month, and make Time#next_month work when invoked on the 31st of a month
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2082 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/time_ext_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index dca810d67e..ca58cd0a8a 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -137,4 +137,28 @@ class TimeExtCalculationsTest < Test::Unit::TestCase midnight = Time.local(2005, 2, 21, 0, 0, 0) assert_equal midnight.midnight, (midnight + 1.hour + 0.000001).midnight end + + def test_days_in_month + assert_equal 31, Time.days_in_month(1, 2005) + + assert_equal 28, Time.days_in_month(2, 2005) + assert_equal 29, Time.days_in_month(2, 2004) + assert_equal 29, Time.days_in_month(2, 2000) + assert_equal 28, Time.days_in_month(2, 1900) + + assert_equal 31, Time.days_in_month(3, 2005) + assert_equal 30, Time.days_in_month(4, 2005) + assert_equal 31, Time.days_in_month(5, 2005) + assert_equal 30, Time.days_in_month(6, 2005) + assert_equal 31, Time.days_in_month(7, 2005) + assert_equal 31, Time.days_in_month(8, 2005) + assert_equal 30, Time.days_in_month(9, 2005) + assert_equal 31, Time.days_in_month(10, 2005) + assert_equal 30, Time.days_in_month(11, 2005) + assert_equal 31, Time.days_in_month(12, 2005) + end + + def test_next_month_on_31st + assert_equal Time.local(2005, 9, 30), Time.local(2005, 8, 31).next_month + end end |