Ignore:
Timestamp:
Aug 15, 2019, 12:31:13 PM (6 years ago)
Author:
[email protected]
Message:

DateConversion::formatDateTime incorrectly formats negative years
https://bugs.webkit.org/show_bug.cgi?id=199964

Patch by Alexey Shvayka <Alexey Shvayka> on 2019-08-15
Reviewed by Ross Kirsling.

JSTests:

  • test262/expectations.yaml: Mark 6 test cases as passing.

Source/JavaScriptCore:

Currently, year is always padded to max length of 4, including the minus sign "-".
With this change, only absolute value of year is padded to max length of 4 and
preceded by minus sign "-" if the year is negative.
(steps 6-10 of https://tc39.es/ecma262/#sec-datestring)

  • runtime/DateConversion.cpp:

(JSC::appendNumber):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/DateConversion.cpp

    r242592 r248738  
    4242static inline void appendNumber(StringBuilder& builder, int value)
    4343{
    44     int fillingZerosCount = width;
    4544    if (value < 0) {
    4645        builder.append('-');
    4746        value = -value;
    48         --fillingZerosCount;
    4947    }
    5048    String valueString = String::number(value);
    51     fillingZerosCount -= valueString.length();
     49    int fillingZerosCount = width - valueString.length();
    5250    for (int i = 0; i < fillingZerosCount; ++i)
    5351        builder.append('0');
Note: See TracChangeset for help on using the changeset viewer.