| Index: src/js/date.js
|
| diff --git a/src/js/date.js b/src/js/date.js
|
| index a99d8e4d51fec8cf3f68f36539ae16ce1133c226..6f004c351f0c5a02b2379ae6179ebe54ed9586cf 100644
|
| --- a/src/js/date.js
|
| +++ b/src/js/date.js
|
| @@ -132,7 +132,7 @@ var Date_cache = {
|
|
|
|
|
| function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
|
| - if (!%_IsConstructCall()) {
|
| + if (IS_UNDEFINED(new.target)) {
|
| // ECMA 262 - 15.9.2
|
| return %_Call(DateToString, new GlobalDate());
|
| }
|
| @@ -140,9 +140,11 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
|
| // ECMA 262 - 15.9.3
|
| var argc = %_ArgumentsLength();
|
| var value;
|
| + var result;
|
| if (argc == 0) {
|
| value = %DateCurrentTime();
|
| - SET_UTC_DATE_VALUE(this, value);
|
| + result = %NewObject(GlobalDate, new.target);
|
| + SET_UTC_DATE_VALUE(result, value);
|
| } else if (argc == 1) {
|
| if (IS_NUMBER(year)) {
|
| value = TimeClip(year);
|
| @@ -169,7 +171,8 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
|
| var time = TO_PRIMITIVE(year);
|
| value = IS_STRING(time) ? DateParse(time) : TO_NUMBER(time);
|
| }
|
| - SET_UTC_DATE_VALUE(this, value);
|
| + result = %NewObject(GlobalDate, new.target);
|
| + SET_UTC_DATE_VALUE(result, value);
|
| } else {
|
| year = TO_NUMBER(year);
|
| month = TO_NUMBER(month);
|
| @@ -184,8 +187,11 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
|
| var day = MakeDay(year, month, date);
|
| var time = MakeTime(hours, minutes, seconds, ms);
|
| value = MakeDate(day, time);
|
| - SET_LOCAL_DATE_VALUE(this, value);
|
| + result = %NewObject(GlobalDate, new.target);
|
| + SET_LOCAL_DATE_VALUE(result, value);
|
| }
|
| +
|
| + return result;
|
| }
|
|
|
|
|
|
|