aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-03-17 03:45:32 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-03-17 03:45:32 +0000
commitb132413885cff785851980dc1740a003109214b7 (patch)
tree074620a90d288f7dc0d291fde30ce763dd79b621 /activesupport/test
parent895487c1224bf85047f317e7bddf4f2abdea0822 (diff)
downloadrails-b132413885cff785851980dc1740a003109214b7.tar.gz
rails-b132413885cff785851980dc1740a003109214b7.tar.bz2
rails-b132413885cff785851980dc1740a003109214b7.zip
Adding TimeZone#at and DateTime#to_f
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9042 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/date_time_ext_test.rb5
-rw-r--r--activesupport/test/time_zone_test.rb19
2 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb
index cb9b6530c9..42aaf0ebad 100644
--- a/activesupport/test/core_ext/date_time_ext_test.rb
+++ b/activesupport/test/core_ext/date_time_ext_test.rb
@@ -271,6 +271,11 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase
assert_equal 0, DateTime.civil(2000) <=> ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 0, 0, 0), TimeZone['UTC'] )
assert_equal(-1, DateTime.civil(2000) <=> ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 0, 0, 1), TimeZone['UTC'] ))
end
+
+ def test_to_f
+ assert_equal 946684800.0, DateTime.civil(2000).to_f
+ assert_equal 946684800.0, DateTime.civil(1999,12,31,19,0,0,Rational(-5,24)).to_f
+ end
protected
def with_env_tz(new_tz = 'US/Eastern')
diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb
index 3ae88db9dd..f5e4e5478a 100644
--- a/activesupport/test/time_zone_test.rb
+++ b/activesupport/test/time_zone_test.rb
@@ -185,6 +185,25 @@ class TimeZoneTest < Test::Unit::TestCase
assert_equal true, twz.dst?
assert_equal 'EDT', twz.zone
end
+
+ def test_at
+ zone = TimeZone['Eastern Time (US & Canada)']
+ secs = 946684800.0
+ twz = zone.at(secs)
+ assert_equal Time.utc(1999,12,31,19), twz.time
+ assert_equal Time.utc(2000), twz.utc
+ assert_equal zone, twz.time_zone
+ assert_equal secs, twz.to_f
+ end
+
+ def test_at_with_old_date
+ zone = TimeZone['UTC']
+ secs = -3786825600.0
+ twz = zone.at(secs)
+ assert_equal [0,0,0,1,1,1850], twz.to_a[0,6]
+ assert_equal zone, twz.time_zone
+ assert_equal secs, twz.to_f
+ end
protected
def with_env_tz(new_tz = 'US/Eastern')