diff options
Diffstat (limited to 'src/qml/jsruntime/qv4dateobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4dateobject.cpp | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index a6e1f47d91..5397ad43c5 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQml module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -198,7 +204,7 @@ static inline double MonthFromTime(double t) else if (d < 365.0 + l) return 11; - return qSNaN(); // ### assert? + return qt_qnan(); // ### assert? } static inline double DateFromTime(double t) @@ -222,7 +228,7 @@ static inline double DateFromTime(double t) case 11: return d - 333.0 - l; } - return qSNaN(); // ### assert + return qt_qnan(); // ### assert } static inline double WeekDay(double t) @@ -254,7 +260,7 @@ static inline double DayFromMonth(double month, double leap) case 11: return 334.0 + leap; } - return qSNaN(); // ### assert? + return qt_qnan(); // ### assert? } static double MakeDay(double year, double month, double day) @@ -332,8 +338,8 @@ static inline double currentTime() static inline double TimeClip(double t) { - if (! qIsFinite(t) || fabs(t) > 8.64e15) - return qSNaN(); + if (! qt_is_finite(t) || fabs(t) > 8.64e15) + return qt_qnan(); return Primitive::toInteger(t); } @@ -538,7 +544,7 @@ static inline double ParseString(const QString &s) } } if (!dt.isValid()) - return qSNaN(); + return qt_qnan(); return dt.toMSecsSinceEpoch(); } @@ -630,7 +636,7 @@ DEFINE_OBJECT_VTABLE(DateObject); Heap::DateObject::DateObject(const QDateTime &date) { - this->date = date.isValid() ? date.toMSecsSinceEpoch() : qSNaN(); + this->date = date.isValid() ? date.toMSecsSinceEpoch() : qt_qnan(); } QDateTime DateObject::toQDateTime() const @@ -764,7 +770,7 @@ double DatePrototype::getThisDate(ExecutionContext *ctx) ReturnedValue DatePrototype::method_parse(CallContext *ctx) { if (!ctx->argc()) - return Encode(qSNaN()); + return Encode(qt_qnan()); return Encode(ParseString(ctx->args()[0].toQString())); } @@ -994,7 +1000,7 @@ ReturnedValue DatePrototype::method_setTime(CallContext *ctx) if (!self) return ctx->engine()->throwTypeError(); - double t = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double t = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(t)); return Encode(self->date()); } @@ -1007,7 +1013,7 @@ ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double ms = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double ms = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))))); return Encode(self->date()); } @@ -1019,7 +1025,7 @@ ReturnedValue DatePrototype::method_setUTCMilliseconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double ms = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double ms = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))); return Encode(self->date()); } @@ -1031,7 +1037,7 @@ ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double sec = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->setDate(t); @@ -1045,7 +1051,7 @@ ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double sec = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))); self->setDate(t); @@ -1059,7 +1065,7 @@ ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double min = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); @@ -1074,7 +1080,7 @@ ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double min = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))); @@ -1089,7 +1095,7 @@ ReturnedValue DatePrototype::method_setHours(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double hour = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); @@ -1105,7 +1111,7 @@ ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double hour = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); @@ -1121,7 +1127,7 @@ ReturnedValue DatePrototype::method_setDate(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double date = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->setDate(t); return Encode(self->date()); @@ -1134,7 +1140,7 @@ ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double date = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))); self->setDate(t); return Encode(self->date()); @@ -1147,7 +1153,7 @@ ReturnedValue DatePrototype::method_setMonth(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double month = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->setDate(t); @@ -1161,7 +1167,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double month = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))); self->setDate(t); @@ -1179,10 +1185,10 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx) t = 0; else t = LocalTime(t); - double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double r; if (std::isnan(year)) { - r = qSNaN(); + r = qt_qnan(); } else { if ((Primitive::toInteger(year) >= 0) && (Primitive::toInteger(year) <= 99)) year += 1900; @@ -1201,7 +1207,7 @@ ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))); @@ -1218,7 +1224,7 @@ ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx) double t = LocalTime(self->date()); if (std::isnan(t)) t = 0; - double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); |