summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-03 19:11:41 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-03 19:11:41 +0000
commit9fa5924294b6d43c8ef6300741bb842a66ee7923 (patch)
tree63daae718bb22b35f58942e30048eb820f57a139 /test
parent43850e265597ef173d6bfcbcfc8f34e92094716c (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_2@51475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_time.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_time.rb b/test/test_time.rb
index f39713b249..2f34464f32 100644
--- a/test/test_time.rb
+++ b/test/test_time.rb
@@ -448,6 +448,17 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
assert_equal(true, t.utc?)
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_strptime_Ymd_z
t = Time.strptime('20010203 -0200', '%Y%m%d %z')
assert_equal(2001, t.year)