diff options
author | Geoff Buesing <gbuesing@gmail.com> | 2008-01-25 23:55:07 +0000 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2008-01-25 23:55:07 +0000 |
commit | dad3e835f77d402aad3b0802ee14bf7a20fd9365 (patch) | |
tree | 8242ac550be31bf80cb5ff616cafc563e942d8b2 /activesupport/test/core_ext/time_with_zone_test.rb | |
parent | 4b2ac708b7666510d522fc706936d3c2ea5cbb80 (diff) | |
download | rails-dad3e835f77d402aad3b0802ee14bf7a20fd9365.tar.gz rails-dad3e835f77d402aad3b0802ee14bf7a20fd9365.tar.bz2 rails-dad3e835f77d402aad3b0802ee14bf7a20fd9365.zip |
Time#- coerces TimeWithZone argument to a Time instance so that difference in seconds can be calculated. Closes #10914 [Geoff Buesing, yyyc514]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8730 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r-- | activesupport/test/core_ext/time_with_zone_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 1a2f3e6e47..9276656db5 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -121,6 +121,16 @@ uses_tzinfo 'TimeWithZoneTest' do def test_minus_with_duration assert_equal Time.utc(1999, 12, 26, 19, 0 ,0), (@twz - 5.days).time end + + def test_minus_with_time + assert_equal 86_400.0, ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2), TimeZone['UTC'] ) - Time.utc(2000, 1, 1) + end + + def test_minus_with_time_with_zone + twz1 = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), TimeZone['UTC'] ) + twz2 = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2), TimeZone['UTC'] ) + assert_equal 86_400.0, twz2 - twz1 + end def test_to_time assert_equal @twz, @twz.to_time |