From 8401218becb5150c722f275cc4d7397fad24c201 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 21 Feb 2005 17:02:08 +0000 Subject: Added Time::Conversions for getting times in different convenient string representations and other objects git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@737 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/time_ext_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activesupport/test/core_ext/time_ext_test.rb') diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index a948d21e17..dabc433c1f 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -86,4 +86,18 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2005,2,29), Time.local(2005,2,22,15,15,10).next_week(:tuesday) assert_equal Time.local(2005,3,4), Time.local(2005,2,22,15,15,10).next_week(:friday) end + + def test_to_s + assert_equal "2005-02-21 17:44:30", Time.local(2005, 2, 21, 17, 44, 30).to_s(:db) + assert_equal "21 Feb 17:44", Time.local(2005, 2, 21, 17, 44, 30).to_s(:short) + assert_equal "21 February, 2005 17:44", Time.local(2005, 2, 21, 17, 44, 30).to_s(:long) + end + + def test_to_date + assert_equal Date.new(2005, 2, 21), Time.local(2005, 2, 21, 17, 44, 30).to_date + end + + def test_to_time + assert_equal Time.local(2005, 2, 21, 17, 44, 30), Time.local(2005, 2, 21, 17, 44, 30).to_time + end end \ No newline at end of file -- cgit v1.2.3