aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4dateobject.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-24 01:00:07 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-24 01:00:07 +0100
commitdf8784fa1fc4792007393ea995756c2d490691d7 (patch)
treed4b8d6bdc855e4045c39f7710f206b7cfcf3d493 /src/qml/jsruntime/qv4dateobject.cpp
parentb799e061a3cbf995ac7c88b315f5916e3a687162 (diff)
parent5246b910771e0dd824b4eea7c5245e5f9f3a63f0 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Diffstat (limited to 'src/qml/jsruntime/qv4dateobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index d8d428237b..21c6a5d06b 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -755,16 +755,16 @@ void Heap::DateCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("Date"));
}
-ReturnedValue DateCtor::virtualCallAsConstructor(const FunctionObject *that, const Value *argv, int argc, const Value *)
+ReturnedValue DateCtor::virtualCallAsConstructor(const FunctionObject *that, const Value *argv, int argc, const Value *newTarget)
{
- ExecutionEngine *e = that->engine();
+ ExecutionEngine *v4 = that->engine();
double t = 0;
if (argc == 0)
t = currentTime();
else if (argc == 1) {
- Scope scope(e);
+ Scope scope(v4);
ScopedValue arg(scope, argv[0]);
if (DateObject *d = arg->as<DateObject>()) {
t = d->date();
@@ -772,7 +772,7 @@ ReturnedValue DateCtor::virtualCallAsConstructor(const FunctionObject *that, con
arg = RuntimeHelpers::toPrimitive(arg, PREFERREDTYPE_HINT);
if (String *s = arg->stringValue())
- t = ParseString(s->toQString(), e->localTZA);
+ t = ParseString(s->toQString(), v4->localTZA);
else
t = TimeClip(arg->toNumber());
}
@@ -789,10 +789,16 @@ ReturnedValue DateCtor::virtualCallAsConstructor(const FunctionObject *that, con
if (year >= 0 && year <= 99)
year += 1900;
t = MakeDate(MakeDay(year, month, day), MakeTime(hours, mins, secs, ms));
- t = TimeClip(UTC(t, e->localTZA));
+ t = TimeClip(UTC(t, v4->localTZA));
}
- return Encode(e->newDateObject(Value::fromDouble(t)));
+ ReturnedValue o = Encode(v4->newDateObject(Value::fromDouble(t)));
+ if (!newTarget)
+ return o;
+ Scope scope(v4);
+ ScopedObject obj(scope, o);
+ obj->setProtoFromNewTarget(newTarget);
+ return obj->asReturnedValue();
}
ReturnedValue DateCtor::virtualCall(const FunctionObject *m, const Value *, const Value *, int)