mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
The implementation was incorrect for negative years and years bigger than 9999. -1 was 000/ because the negative (year%10) was added to '0' character, years bigger than 9999 was truncated to 4 digits. ES5.1 15.9.1.15.1 defines extended years format with 6 digits, but toString() and toISOString() sections don't mention anything about extended years. ES6 20.3.4.3 already clarifies that Date.prototype.toISOString() should use this extended year format if it is necessary. Changes: - Date.prototype.toString() uses 4 digits for years by default, 5 or 6 if it is necessary and put '-' sign for negative years, no sign for positive years. Date.prototype.toString() was implementation dependent until ES9, but ES9 already specify exactly this format. - Date.prototype.toISOString() uses fixed 4 digits for years 0 - 9999, otherwise sign + 6 digits (extended years). - Tests added for corner cases. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu