TimeClip converts -0 to +0, following ES2015 spec

In ES2015, section 20.3.1.15, TimeClip (an internal algorihtm which is
called when normalizing Date representations) is specified to add 0
to its result, which converts -0 into +0. This patch adds that conversion
to the Date code. It is verified by the test262 test
built-ins/Date/TimeClip_negative_zero

R=adamk

Review URL: https://codereview.chromium.org/1387293002

Cr-Commit-Position: refs/heads/master@{#31159}
This commit is contained in:
littledan 2015-10-07 11:17:46 -07:00 committed by Commit bot
parent 7c7d192a93
commit eeaf80cd86

View File

@ -116,7 +116,7 @@ function MakeDate(day, time) {
function TimeClip(time) {
if (!IsFinite(time)) return NAN;
if (MathAbs(time) > MAX_TIME_MS) return NAN;
return TO_INTEGER(time);
return TO_INTEGER(time) + 0;
}
@ -144,7 +144,7 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
SET_UTC_DATE_VALUE(this, value);
} else if (argc == 1) {
if (IS_NUMBER(year)) {
value = year;
value = TimeClip(year);
} else if (IS_STRING(year)) {
// Probe the Date cache. If we already have a time value for the