From f73f9e42f4e6987ff53e3bd5e53a5040b04f9f36 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 24 Feb 2005 11:56:09 +0000 Subject: Made TimeZone even more delicious #709 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@787 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/time_zone_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activesupport/test/time_zone_test.rb') diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index 66f1a1b058..3e35c327e0 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -6,6 +6,10 @@ class TimeZoneTest < Test::Unit::TestCase def self.now Time.utc( 2004, 7, 25, 14, 49, 00 ) end + + def self.local(*args) + Time.utc(*args) + end end TimeZone::Time = MockTime @@ -25,6 +29,11 @@ class TimeZoneTest < Test::Unit::TestCase assert_equal Time.local(2004,7,25,15,59,00).to_a[0,6], zone.now.to_a[0,6] end + def test_today + zone = TimeZone.create( "Test", 43200 ) + assert_equal Date.new(2004,7,26), zone.today + end + def test_adjust_negative zone = TimeZone.create( "Test", -4200 ) assert_equal Time.utc(2004,7,24,23,55,0), zone.adjust(Time.utc(2004,7,25,1,5,0)) @@ -35,6 +44,13 @@ class TimeZoneTest < Test::Unit::TestCase assert_equal Time.utc(2004,7,26,1,5,0), zone.adjust(Time.utc(2004,7,25,23,55,0)) end + def test_unadjust + zone = TimeZone.create( "Test", 4200 ) + expect = Time.utc(2004,7,24,23,55,0).to_a[0,6] + actual = zone.unadjust(Time.utc(2004,7,25,1,5,0)).to_a[0,6] + assert_equal expect, actual + end + def test_zone_compare zone1 = TimeZone.create( "Test1", 4200 ) zone2 = TimeZone.create( "Test1", 5600 ) -- cgit v1.2.3