From e52b102c36dc1dd609a97149e99edc7d1f96b7a4 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 8 Jan 2019 07:45:04 +0000 Subject: [PATCH] Test for "%p" in Time.strptime git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_time.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_time.rb b/test/test_time.rb index fb30bea723..e4fea31945 100644 --- a/test/test_time.rb +++ b/test/test_time.rb @@ -509,6 +509,25 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc: assert_equal(1, t.day) end + def test_strptime_p + t = Time.strptime("3am", "%I%p") + assert_equal(3, t.hour) + t = Time.strptime("3pm", "%I%p") + assert_equal(15, t.hour) + t = Time.strptime("3a.m.", "%I%p") + assert_equal(3, t.hour) + t = Time.strptime("3p.m.", "%I%p") + assert_equal(15, t.hour) + t = Time.strptime("3AM", "%I%p") + assert_equal(3, t.hour) + t = Time.strptime("3PM", "%I%p") + assert_equal(15, t.hour) + t = Time.strptime("3A.M.", "%I%p") + assert_equal(3, t.hour) + t = Time.strptime("3P.M.", "%I%p") + assert_equal(15, t.hour) + end + def test_nsec assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec) end