diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-30 06:24:32 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-30 06:24:32 +0000 |
commit | b7d2dae6dcf00b38a1dba8687d6b70d863da915e (patch) | |
tree | 7bbc63855cf78b39a60abc1fd1f26b970cc56890 /activesupport/test/core_ext/date_time_ext_test.rb | |
parent | 6503da69910beb382b18127c51cd318631245607 (diff) | |
download | rails-b7d2dae6dcf00b38a1dba8687d6b70d863da915e.tar.gz rails-b7d2dae6dcf00b38a1dba8687d6b70d863da915e.tar.bz2 rails-b7d2dae6dcf00b38a1dba8687d6b70d863da915e.zip |
DateTime#to_time converts to Time unless out of range. Date#to_datetime and Date#to_s(:rfc822). Closes #8512.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6902 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/date_time_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/date_time_ext_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
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 |