Bug 199964 - DateConversion::formatDateTime incorrectly formats negative years
Summary: DateConversion::formatDateTime incorrectly formats negative years
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Minor
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-07-19 15:17 PDT by Alexey Shvayka
Modified: 2019-08-15 12:32 PDT (History)
9 users (show)

See Also:


Attachments
Patch (4.43 KB, patch)
2019-07-19 15:33 PDT, Alexey Shvayka
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Shvayka 2019-07-19 15:17:16 PDT
Test case:
d = new Date; d.setFullYear(-12); d.toUTCString().split(" ")[3]

Expected:
"-0012"
Math.abs(year) should be padded to length of 4 and preceded with "-" if year < 0.

Actual:
"-012"
JSC always pads year to length of 4, including minus sign "-".

Other browsers engines comply with the spec.

ECMA262: https://tc39.es/ecma262/#sec-datestring (steps 6-10)
Test262:
  https://test262.report/browse/built-ins/Date/prototype/toDateString/negative-year.js
  https://test262.report/browse/built-ins/Date/prototype/toString/negative-year.js
  https://test262.report/browse/built-ins/Date/prototype/toUTCString/invalid-date.js
Comment 1 Alexey Shvayka 2019-07-19 15:33:02 PDT
Created attachment 374510 [details]
Patch
Comment 2 WebKit Commit Bot 2019-08-15 12:31:20 PDT
Comment on attachment 374510 [details]
Patch

Clearing flags on attachment: 374510

Committed r248738: <https://trac.webkit.org/changeset/248738>
Comment 3 WebKit Commit Bot 2019-08-15 12:31:21 PDT
All reviewed patches have been landed.  Closing bug.
Comment 4 Radar WebKit Bug Importer 2019-08-15 12:32:16 PDT
<rdar://problem/54358160>