| Index: src/date.js
|
| diff --git a/src/date.js b/src/date.js
|
| index 2be8bcb220a7f3ed91ea1fb6943fa79398d5e4a7..44d2f4df1639044f19958d914c858bdc87760508 100644
|
| --- a/src/date.js
|
| +++ b/src/date.js
|
| @@ -364,6 +364,21 @@ function DateToLocaleTimeString() {
|
| }
|
|
|
|
|
| +// 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint )
|
| +function DateToPrimitive(hint) {
|
| + if (!IS_SPEC_OBJECT(this)) {
|
| + throw MakeTypeError(kIncompatibleMethodReceiver,
|
| + "Date.prototype [ @@toPrimitive ]", this);
|
| + }
|
| + if (hint === "default") {
|
| + hint = "string";
|
| + } else if (hint !== "number" && hint !== "string") {
|
| + throw MakeTypeError(kInvalidHint, hint);
|
| + }
|
| + return %OrdinaryToPrimitive(this, hint);
|
| +}
|
| +
|
| +
|
| // ECMA 262 - 15.9.5.8
|
| function DateValueOf() {
|
| CHECK_DATE(this);
|
| @@ -777,9 +792,10 @@ function DateToISOString() {
|
| }
|
|
|
|
|
| +// 20.3.4.37 Date.prototype.toJSON ( key )
|
| function DateToJSON(key) {
|
| var o = TO_OBJECT(this);
|
| - var tv = $defaultNumber(o);
|
| + var tv = TO_PRIMITIVE_NUMBER(o);
|
| if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) {
|
| return null;
|
| }
|
| @@ -831,6 +847,9 @@ utils.InstallFunctions(GlobalDate, DONT_ENUM, [
|
|
|
| // Set up non-enumerable constructor property of the Date prototype object.
|
| %AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM);
|
| +utils.SetFunctionName(DateToPrimitive, symbolToPrimitive);
|
| +%AddNamedProperty(GlobalDate.prototype, symbolToPrimitive, DateToPrimitive,
|
| + DONT_ENUM | READ_ONLY);
|
|
|
| // Set up non-enumerable functions of the Date prototype object and
|
| // set their names.
|
|
|