diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-24 11:56:09 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-24 11:56:09 +0000 |
commit | f73f9e42f4e6987ff53e3bd5e53a5040b04f9f36 (patch) | |
tree | 2c86776b4369ba5127762fb6cea356b9c8f3af8a /activesupport/test | |
parent | 02df588cf79cc3738278aea501a2d219afb783b5 (diff) | |
download | rails-f73f9e42f4e6987ff53e3bd5e53a5040b04f9f36.tar.gz rails-f73f9e42f4e6987ff53e3bd5e53a5040b04f9f36.tar.bz2 rails-f73f9e42f4e6987ff53e3bd5e53a5040b04f9f36.zip |
Made TimeZone even more delicious #709
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@787 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/time_zone_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
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 ) |