new Date(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
date.getMilliseconds(),
);
Pass
new Date(date)
Proposed rule name
consistent-date-clone
Additional Info
Note: new Date(date) doesn't work before ES6
Let v be ToPrimitive(value).
If Type(v) is String, then
Parse v as a date, in exactly the same manner as for the parse method (15.9.4.2); let V be the time value for this date.
Else, let V be ToNumber(v).
Set the [[PrimitiveValue]] internal property of the newly constructed object to TimeClip(V) and return
Description
I just learned that
Date
constructor acceptsDate
since ES6.https://262.ecma-international.org/6.0/#sec-date-constructor
Fail
Pass
Proposed rule name
consistent-date-clone
Additional Info
Note:
new Date(date)
doesn't work before ES6https://262.ecma-international.org/5.1/#sec-15.9.3.2