From 637642c8b85707779af45f80a104dd84be6a904d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 21 Feb 2005 14:32:55 +0000 Subject: Treat UTC times nicer git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@732 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/time_ext_test.rb | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (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 ecad949c94..1918b01b23 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -62,23 +62,22 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2005,2,23,10,10,10), Time.local(2005,2,22,10,10,10).tomorrow assert_equal Time.local(2005,3,2,10,10,10), Time.local(2005,2,28,10,10,10).tomorrow.tomorrow end - - def test_in_the_morning - assert_equal Time.local(2005,2,22,9), Time.local(2005,2,22,15,15,10).in_the_morning - assert_equal Time.local(2005,2,22,9), Time.local(2005,2,22,3,15,10).in_the_morning - end - - def test_in_the_morning - assert_equal Time.local(2005,2,22,14), Time.local(2005,2,22,15,15,10).in_the_afternoon - assert_equal Time.local(2005,2,22,14), Time.local(2005,2,22,3,15,10).in_the_afternoon - end def test_change assert_equal Time.local(2006,2,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:year => 2006) assert_equal Time.local(2005,6,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:month => 6) assert_equal Time.local(2012,9,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:year => 2012, :month => 9) - assert_equal Time.local(2005,2,22,16), Time.local(2005,2,22,15,15,10).change(:hour => 16) - assert_equal Time.local(2005,2,22,16,45), Time.local(2005,2,22,15,15,10).change(:hour => 16, :min => 45) - assert_equal Time.local(2005,2,22,15,45), Time.local(2005,2,22,15,15,10).change(:min => 45) + assert_equal Time.local(2005,2,22,16), Time.local(2005,2,22,15,15,10).change(:hour => 16) + assert_equal Time.local(2005,2,22,16,45), Time.local(2005,2,22,15,15,10).change(:hour => 16, :min => 45) + assert_equal Time.local(2005,2,22,15,45), Time.local(2005,2,22,15,15,10).change(:min => 45) + end + + def test_utc_change + assert_equal Time.utc(2006,2,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:year => 2006) + assert_equal Time.utc(2005,6,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:month => 6) + assert_equal Time.utc(2012,9,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:year => 2012, :month => 9) + assert_equal Time.utc(2005,2,22,16), Time.utc(2005,2,22,15,15,10).change(:hour => 16) + assert_equal Time.utc(2005,2,22,16,45), Time.utc(2005,2,22,15,15,10).change(:hour => 16, :min => 45) + assert_equal Time.utc(2005,2,22,15,45), Time.utc(2005,2,22,15,15,10).change(:min => 45) end end \ No newline at end of file -- cgit v1.2.3