Changeset 248738 in webkit


Ignore:
Timestamp:
Aug 15, 2019 12:31:13 PM (5 years ago)
Author:
commit-queue@webkit.org
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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r248716 r248738  
     12019-08-15  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        DateConversion::formatDateTime incorrectly formats negative years
     4        https://bugs.webkit.org/show_bug.cgi?id=199964
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * test262/expectations.yaml: Mark 6 test cases as passing.
     9
    1102019-08-15  Mark Lam  <mark.lam@apple.com>
    211
  • trunk/JSTests/test262/expectations.yaml

    r248115 r248738  
    859859  default: 'TypeError: Type error'
    860860  strict mode: 'TypeError: Type error'
    861 test/built-ins/Date/prototype/toDateString/negative-year.js:
    862   default: 'Test262Error: Date.prototype.toDateString serializes year -1 to "-0001" Expected SameValue(«-001», «-0001») to be true'
    863   strict mode: 'Test262Error: Date.prototype.toDateString serializes year -1 to "-0001" Expected SameValue(«-001», «-0001») to be true'
    864861test/built-ins/Date/prototype/toJSON/invoke-result.js:
    865862  default: 'TypeError: toISOString did not return a primitive value'
     
    874871  default: 'TypeError: toISOString did not return a primitive value'
    875872  strict mode: 'TypeError: toISOString did not return a primitive value'
    876 test/built-ins/Date/prototype/toString/negative-year.js:
    877   default: 'Test262Error: Date.prototype.toString serializes year -1 to "-0001" Expected SameValue(«-001», «-0001») to be true'
    878   strict mode: 'Test262Error: Date.prototype.toString serializes year -1 to "-0001" Expected SameValue(«-001», «-0001») to be true'
    879 test/built-ins/Date/prototype/toUTCString/negative-year.js:
    880   default: 'Test262Error: Date.prototype.toUTCString serializes year -1 to "-0001" Expected SameValue(«-001», «-0001») to be true'
    881   strict mode: 'Test262Error: Date.prototype.toUTCString serializes year -1 to "-0001" Expected SameValue(«-001», «-0001») to be true'
    882873test/built-ins/Error/proto-from-ctor-realm.js:
    883874  default: 'Test262Error: Expected SameValue(«Error», «Error») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r248716 r248738  
     12019-08-15  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        DateConversion::formatDateTime incorrectly formats negative years
     4        https://bugs.webkit.org/show_bug.cgi?id=199964
     5
     6        Reviewed by Ross Kirsling.
     7
     8        Currently, year is always padded to max length of 4, including the minus sign "-".
     9        With this change, only absolute value of year is padded to max length of 4 and
     10        preceded by minus sign "-" if the year is negative.
     11        (steps 6-10 of https://tc39.es/ecma262/#sec-datestring)
     12
     13        * runtime/DateConversion.cpp:
     14        (JSC::appendNumber):
     15
    1162019-08-15  Mark Lam  <mark.lam@apple.com>
    217
  • 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.