diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-05 02:39:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-05 02:39:55 +0000 |
commit | 88083fa47e90c1a600da5e014e7ff0488eb5883c (patch) | |
tree | 5f2a2b5102483d20234ae35b6cd7176be9c22293 | |
parent | 32c4fd7aa36b358bb132995f7a4dcfdc2d5508ea (diff) | |
download | ruby-88083fa47e90c1a600da5e014e7ff0488eb5883c.tar.gz |
rss.rb: fix usec width
* lib/rss/rss.rb (Time#w3cdtf): fix zero-trimmed width of fraction
digits. [ruby-core:70667] [Bug #11509]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/rss/rss.rb | 2 | ||||
-rw-r--r-- | test/rss/test_to_s.rb | 6 |
3 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Sat Sep 5 11:39:52 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/rss/rss.rb (Time#w3cdtf): fix zero-trimmed width of fraction + digits. [ruby-core:70667] [Bug #11509] + Sat Sep 5 08:28:58 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * hash.c (rb_hash_equal, rb_hash_eql): [DOC] the orders of each diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb index 4f6732b4d2..224b576154 100644 --- a/lib/rss/rss.rb +++ b/lib/rss/rss.rb @@ -53,7 +53,7 @@ class Time if usec.zero? fraction_digits = 0 else - fraction_digits = Math.log10(usec.to_s.sub(/0*$/, '').to_i).floor + 1 + fraction_digits = strftime('%6N').sub!(/0*\z/, '').size end xmlschema(fraction_digits) end diff --git a/test/rss/test_to_s.rb b/test/rss/test_to_s.rb index 4ef83ce18b..d97cf9d4b0 100644 --- a/test/rss/test_to_s.rb +++ b/test/rss/test_to_s.rb @@ -102,6 +102,12 @@ module RSS assert_textinput20(@textinput_info, rss.textinput) end + def test_time_w3cdtf + assert_equal("2015-09-05T01:25:48.0001Z", + Time.utc(2015, 9, 5, 1, 25, 48, 100).w3cdtf, + '[ruby-core:70667] [Bug #11509]') + end + private def setup_xml_declaration_info @version = "1.0" |