From: usa@...
Date: 2015-09-29T08:34:24+00:00
Subject: [ruby-core:70944] [Ruby trunk - Bug #11509] Incorrect fraction_digits calculation in lib/rss/rss.rb:41 Time#w3cdtf
Issue #11509 has been updated by Usaku NAKAMURA.
Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE, 2.2: REQUIRED
ruby_2_1 r51977 merged revision(s) 51766,51767.
----------------------------------------
Bug #11509: Incorrect fraction_digits calculation in lib/rss/rss.rb:41 Time#w3cdtf
https://bugs.ruby-lang.org/issues/11509#change-54307
* Author: Victor Maslov
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: 2.0.0p451
* Backport: 2.0.0: REQUIRED, 2.1: DONE, 2.2: REQUIRED
----------------------------------------
Current code is:
~~~ruby
fraction_digits = Math.log10(usec.to_s.sub(/0*$/, '').to_i).floor + 1
~~~
This makes time to lose as many digits, as there are zeros right after dot:
~~~diff
< 2014-03-04T07:37:30.04253+04:00
> 2014-03-04T07:37:30.0425+04:00
~~~
My solution that solves the issue is:
~~~ruby
fraction_digits = (usec + 1000000).to_s.length - 1
~~~
My Ruby is 2.0.0, but looks like noone touched RSS module for a year, so the bug is still here: https://bugs.ruby-lang.org/projects/ruby-trunk/repository/entry/lib/rss/rss.rb#L56
--
https://bugs.ruby-lang.org/