Bug 199964

Summary: DateConversion::formatDateTime incorrectly formats negative years
Product: WebKit Reporter: Alexey Shvayka <ashvayka>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Minor CC: commit-queue, ews-watchlist, keith_miller, mark.lam, msaboff, ross.kirsling, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch none

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>