diff options
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/date_ext_test.rb | 8 | ||||
-rw-r--r-- | activesupport/test/core_ext/date_time_ext_test.rb | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 6a0508b8c4..3557c11748 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -6,14 +6,16 @@ class DateExtCalculationsTest < Test::Unit::TestCase assert_equal "February 21, 2005", Date.new(2005, 2, 21).to_s(:long) assert_equal "February 21st, 2005", Date.new(2005, 2, 21).to_s(:long_ordinal) assert_equal "2005-02-21", Date.new(2005, 2, 21).to_s(:db) + assert_equal "21 Feb 2005", Date.new(2005, 2, 21).to_s(:rfc822) end def test_to_time assert_equal Time.local(2005, 2, 21), Date.new(2005, 2, 21).to_time + assert_equal Time.local_time(2039, 2, 21), Date.new(2039, 2, 21).to_time end - - def test_to_time_on_datetime - assert_equal Time.local(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12).to_time + + def test_to_datetime + assert_equal DateTime.civil(2005, 2, 21), Date.new(2005, 2, 21).to_datetime end def test_to_date diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index 0aacf123c3..b5d80295f0 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -21,6 +21,12 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase def test_to_date assert_equal Date.new(2005, 2, 21), DateTime.new(2005, 2, 21).to_date end + + def test_to_time + assert_equal Time.utc(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12, 0, 0).to_time + assert_equal Time.local(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24), 0).to_time + assert_equal Time.utc_time(2039, 2, 21, 10, 11, 12), DateTime.new(2039, 2, 21, 10, 11, 12, 0, 0).to_time + end def test_seconds_since_midnight assert_equal 1,DateTime.civil(2005,1,1,0,0,1).seconds_since_midnight |