I just learned that Date
constructor accepts Date
since ES6.
If Type(value) is Object and value has a [[DateValue]] internal slot, then
Let tv be thisTimeValue(value).
https://262.ecma-international.org/6.0/#sec-date-constructor
new Date(date.getTime());
new Date(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
date.getMilliseconds(),
);
new Date(date)
consistent-date-clone
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
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too