Following test case in LayoutTests/fast/forms/datetime/input-valueasnumber-datetime.html is failed: shouldBe('setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1)', '"275760-09-12T00:00:00.001Z"'); The root cause is Decimal::toString. It converts an integer 8639999913600001 (= Date.UTC(275760, 8, 12, 0, 0, 0 1)) to a string "8639999913600000", the last digit "1" is converted to digit "0".
Created attachment 152724 [details] Patch 1
Comment on attachment 152724 [details] Patch 1 Could you review this patch? Thanks in advance. P.S. Changes for Decimal.cpp is only adding "if (originalExponent < 0)" and indentation. git diff -w Decimal.cpp shows two line changes.
Comment on attachment 152724 [details] Patch 1 View in context: https://bugs.webkit.org/attachment.cgi?id=152724&action=review > Source/WebCore/ChangeLog:14 > + (WebCore::Decimal::toString): When the value is an integer, we don't > + round coefficient to DBL_DIG(15) digits. Why do we need the rounding for non-integer cases? > Source/WebKit/chromium/tests/DecimalTest.cpp:1045 > + // 8639999913600001=Date.UTC(275760, 8, 12, 0, 0, 0 1) Understing it helps nothing. Please remove the comment. > Source/WebKit/chromium/tests/DecimalTest.cpp:1046 > + EXPECT_STREQ(("8639999913600001"), encode(8639999913600001, 0, Positive).toString().ascii().data()); We need more test cases. For example, MaxCoefficient with various exponents.
Created attachment 152904 [details] Patch 2
Created attachment 152949 [details] Patch 3
(In reply to comment #3) > (From update of attachment 152724 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=152724&action=review > > > Source/WebCore/ChangeLog:14 > > + (WebCore::Decimal::toString): When the value is an integer, we don't > > + round coefficient to DBL_DIG(15) digits. > > Why do we need the rounding for non-integer cases? The reason is we would like to get "1" for 1/3 * 3 or 1/256 * 256. Using DBL_DIG is chosen by converting Decimal to double, e.g. HTMLInputElement.valueAsNumber method.
Comment on attachment 152949 [details] Patch 3 Could you review this patch? Thanks in advance. = Changes since the last review = * Added more tests as suggested. * Use newly introduced macro EXPECT_DECIMAL_STREQ.
Comment on attachment 152949 [details] Patch 3 ok
Comment on attachment 152949 [details] Patch 3 Clearing flags on attachment: 152949 Committed r122928: <http://trac.webkit.org/changeset/122928>
All reviewed patches have been landed. Closing bug.