diff options
author | Andrew White <andrew.white@unboxedconsulting.com> | 2016-04-23 19:11:34 +0100 |
---|---|---|
committer | Andrew White <andrew.white@unboxedconsulting.com> | 2016-04-23 19:11:34 +0100 |
commit | 88d844b278163f19e910fc1acadf1dbb4afac527 (patch) | |
tree | 8d82572a80ad5058946c34729d88e331c35f2c71 /activesupport/test/core_ext/time_ext_test.rb | |
parent | dbc7a7cb509ef0046afa327d4ac8330259fd8e73 (diff) | |
download | rails-88d844b278163f19e910fc1acadf1dbb4afac527.tar.gz rails-88d844b278163f19e910fc1acadf1dbb4afac527.tar.bz2 rails-88d844b278163f19e910fc1acadf1dbb4afac527.zip |
Change Time#sec_fraction to use subsec
Time instances can have fractional parts smaller than a nanosecond.
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/time_ext_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index d8bb38621b..1205797fac 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -107,6 +107,20 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase end end + def test_sec_fraction + time = Time.utc(2016, 4, 23, 0, 0, Rational(1,10000000000)) + assert_equal Rational(1,10000000000), time.sec_fraction + + time = Time.utc(2016, 4, 23, 0, 0, 0.0000000001) + assert_equal 0.0000000001.to_r, time.sec_fraction + + time = Time.utc(2016, 4, 23, 0, 0, 0, Rational(1,10000)) + assert_equal Rational(1,10000000000), time.sec_fraction + + time = Time.utc(2016, 4, 23, 0, 0, 0, 0.0001) + assert_equal 0.0001.to_r / 1000000, time.sec_fraction + end + def test_beginning_of_day assert_equal Time.local(2005,2,4,0,0,0), Time.local(2005,2,4,10,10,10).beginning_of_day with_env_tz 'US/Eastern' do |