From: niroyb@... Date: 2015-11-19T20:02:02+00:00 Subject: [ruby-core:71589] [Ruby trunk - Bug #11716] [Open] Truncation error in Time xmlschema with fraction_digits. Issue #11716 has been reported by Nick R. ---------------------------------------- Bug #11716: Truncation error in Time xmlschema with fraction_digits. https://bugs.ruby-lang.org/issues/11716 * Author: Nick R * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- It looks like xmlschema with the fraction_digits parameter truncates the fractional second part. Sometimes it truncates too much. ex : 1447961542.26 with 2 fraction digits gives 1447961542.25 instead of 1447961542.26 Could be due to floating point representation. But tests seem to indicate otherwise. `$ irb $ require 'time' => true $ Time.at(1447961542.26).xmlschema(2) => "2015-11-19T11:32:22.25-08:00" $ Time.at(1447961542.269).xmlschema(2) => "2015-11-19T11:32:22.26-08:00" $ Time.at(1447961542.259).xmlschema(2) => "2015-11-19T11:32:22.25-08:00" $ Time.at(1447961542.25).xmlschema(2) => "2015-11-19T11:32:22.25-08:00" $ 1447961542.26*100.floor => 144796154226.0 ` -- https://bugs.ruby-lang.org/