diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-17 07:41:58 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-17 07:41:58 +0000 |
commit | a61756e094462e6548113a7407652230f1f85161 (patch) | |
tree | 94706a5d2b7c58431c5b7750173c005671b3c356 /test | |
parent | 7766666aed80c7e06dfd8288302a663638b66fe5 (diff) |
merge revision(s) 49788,49790: [Backport #10904]
* lib/time.rb (strptime): Support %s.%N.
[ruby-core:68301] [Bug #10904] Patch by Sadayuki Furuhashi.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/test_time.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_time.rb b/test/test_time.rb index 582e60b8ae..12c8589209 100644 --- a/test/test_time.rb +++ b/test/test_time.rb @@ -404,6 +404,17 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc: assert_equal(3600, Time.strptime('0 +0100', '%s %z').utc_offset) end + def test_strptime_s_N + assert_equal(Time.at(1, 500000), Time.strptime("1.5", "%s.%N")) + assert_equal(Time.at(-2, 500000), Time.strptime("-1.5", "%s.%N")) + t = Time.strptime("1.000000000001", "%s.%N") + assert_equal(1, t.to_i) + assert_equal(Rational("0.000000000001"), t.subsec) + t = Time.strptime("-1.000000000001", "%s.%N") + assert_equal(-2, t.to_i) + assert_equal(1-Rational("0.000000000001"), t.subsec) + end + def test_nsec assert_equal(123456789, Time.xmlschema("2000-01-01T00:00:00.123456789+00:00").tv_nsec) assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec) |