aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
diff options
context:
space:
mode:
authorVasiliy Ermolovich + Sergey Nartimov <younash@gmail.com>2012-05-18 13:07:52 +0300
committerVasiliy Ermolovich <younash@gmail.com>2012-05-18 13:07:52 +0300
commitdcdde7da481e11660634278a8004175a1ce20f39 (patch)
treec30f862c6fe10403152ffe0aa89ccc79a85ba005 /activesupport/test/core_ext/time_with_zone_test.rb
parente2e513621d732abb8efff9120bd9a444836720d6 (diff)
downloadrails-dcdde7da481e11660634278a8004175a1ce20f39.tar.gz
rails-dcdde7da481e11660634278a8004175a1ce20f39.tar.bz2
rails-dcdde7da481e11660634278a8004175a1ce20f39.zip
respect nsec in TimeWithZone
when we pass fractional usec to Time methods we should use Rational instead of Float because of accuracy problem Time.local(2011,6,12,23,59,59,999999.999).nsec # => 999999998 Time.local(2011,6,12,23,59,59,Rational(999999999, 1000)).nsec # => 999999999
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb8
1 files changed, 8 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 b62337e31b..1293f104e5 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -80,6 +80,14 @@ class TimeWithZoneTest < ActiveSupport::TestCase
ActiveSupport.use_standard_json_time_format = old
end
+ def test_nsec
+ local = Time.local(2011,6,7,23,59,59,Rational(999999999, 1000))
+ with_zone = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Hawaii"], local)
+
+ assert_equal local.nsec, with_zone.nsec
+ assert_equal with_zone.nsec, 999999999
+ end
+
def test_strftime
assert_equal '1999-12-31 19:00:00 EST -0500', @twz.strftime('%Y-%m-%d %H:%M:%S %Z %z')
end