aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-06-13 12:01:12 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2013-06-13 12:01:12 +0100
commit17f5d8e062909f1fcae25351834d8e89967b645e (patch)
treef0be19ac442bf39a41bc8b0b2a7231d7459802c6 /activesupport/test/core_ext/time_with_zone_test.rb
parentb3bc3aa5cbe7540de21ae4eb566886e3b8efe6e3 (diff)
downloadrails-17f5d8e062909f1fcae25351834d8e89967b645e.tar.gz
rails-17f5d8e062909f1fcae25351834d8e89967b645e.tar.bz2
rails-17f5d8e062909f1fcae25351834d8e89967b645e.zip
Keep sub-second resolution when wrapping a DateTime value
Add `DateTime#usec` and `DateTime#nsec` so that `ActiveSupport::TimeWithZone` keeps sub-second resolution when wrapping a `DateTime` value. Fixes #10855
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb5
1 files changed, 5 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 3ce3297874..e8eea27d72 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -445,6 +445,11 @@ class TimeWithZoneTest < ActiveSupport::TestCase
assert_equal 0, twz.usec
end
+ def test_usec_returns_sec_fraction_when_datetime_is_wrapped
+ twz = ActiveSupport::TimeWithZone.new(DateTime.civil(2000, 1, 1, 0, 0, Rational(1,2)), @time_zone)
+ assert_equal 500000, twz.usec
+ end
+
def test_utc_to_local_conversion_saves_period_in_instance_variable
assert_nil @twz.instance_variable_get('@period')
@twz.time