8#include <QtCore/QDebug>
9#include <QtCore/QDateTime>
10#include <QtCore/private/qlocaltime_p.h>
11#include <QtCore/QStringList>
12#include <QtCore/QTimeZone>
14#include <wtf/MathExtras.h>
56static inline double Day(
double t)
66 else if (::fmod(
y, 100))
69 else if (::fmod(
y, 400))
77 return 365 * (
y - 1970)
78 + ::floor((
y - 1969) / 4)
79 - ::floor((
y - 1901) / 100)
80 + ::floor((
y - 1601) / 400);
120 else if (
d < 59.0 + l)
123 else if (
d < 90.0 + l)
126 else if (
d < 120.0 + l)
129 else if (
d < 151.0 + l)
132 else if (
d < 181.0 + l)
135 else if (
d < 212.0 + l)
138 else if (
d < 243.0 + l)
141 else if (
d < 273.0 + l)
144 else if (
d < 304.0 + l)
147 else if (
d < 334.0 + l)
150 else if (
d < 365.0 + l)
163 case 0:
return d + 1.0;
164 case 1:
return d - 30.0;
165 case 2:
return d - 58.0 - l;
166 case 3:
return d - 89.0 - l;
167 case 4:
return d - 119.0 - l;
168 case 5:
return d - 150.0 - l;
169 case 6:
return d - 180.0 - l;
170 case 7:
return d - 211.0 - l;
171 case 8:
return d - 242.0 - l;
172 case 9:
return d - 272.0 - l;
173 case 10:
return d - 303.0 - l;
174 case 11:
return d - 333.0 - l;
182 double r = ::fmod (
Day(
t) + 4.0, 7.0);
183 return (
r >= 0) ?
r :
r + 7.0;
187static inline double MakeTime(
double hour,
double min,
double sec,
double ms)
200 switch ((
int) month) {
203 case 2:
return 59.0 + leap;
204 case 3:
return 90.0 + leap;
205 case 4:
return 120.0 + leap;
206 case 5:
return 151.0 + leap;
207 case 6:
return 181.0 + leap;
208 case 7:
return 212.0 + leap;
209 case 8:
return 243.0 + leap;
210 case 9:
return 273.0 + leap;
211 case 10:
return 304.0 + leap;
212 case 11:
return 334.0 + leap;
218static double MakeDay(
double year,
double month,
double day)
226 year += ::floor(month / 12.0);
228 month = ::fmod(month, 12.0);
250 qWarning(
"Apparently out-of-range date %.0f-%02.0f-%02.0f", year, month, day);
253 return first + day - 1;
292static inline double UTC(
double t,
double localTZA)
348 bool extendedYear =
false;
364 if (*
ch == u
'+' || *
ch == u
'-') {
371 if (*
ch >= u
'0' && *
ch <= u
'9') {
373 current +=
ch->unicode() - u
'0';
380 error = (currentSize != 6);
382 error = (currentSize != 4);
386 error = (currentSize != 2) || month > 11;
390 error = (currentSize != 2) || day > 31;
394 error = (currentSize != 2) || hour > 24;
398 error = (currentSize != 2) || minute >= 60;
402 error = (currentSize != 2) || second > 60;
406 error = (currentSize != 3);
411 error = (currentSize != 2) || current > 23;
416 error = (currentSize != 2) || current >= 60;
424 }
else if (*
ch == u
'-') {
429 else if (
format >= TimezoneHour)
436 }
else if (*
ch == u
':') {
440 }
else if (*
ch == u
'.') {
444 }
else if (*
ch == u
'+') {
445 if (seenZ || format < Minute || format >= TimezoneHour)
448 }
else if (*
ch == u
'Z') {
449 if (seenZ || format < Minute || format >= TimezoneHour)
455 }
else if (
ch->unicode() == 0) {
466 t -=
offset * offsetSign * 60 * 1000;
468 t =
UTC(
t, localTZA);
535 : QDateTime::fromString(
s,
format);
565 int hours =
static_cast<int>(::fabs(tzoffset) / 1000 / 60 / 60);
566 int mins = int(::fabs(tzoffset) / 1000 / 60) % 60;
620 return InvalidDateVal;
642 storage =
encode(when) | HasQDate | HasQTime;
671 static const double d =
MakeDay(1971, 3, 1);
693 switch (storage & (HasQDate | HasQTime)) {
698 case (HasQDate | HasQTime):
707 return d()->toQDateTime();
760 else if (argc == 1) {
778 double day = argc >= 3 ? argv[2].
toNumber() : 1;
779 double hours = argc >= 4 ? argv[3].
toNumber() : 0;
780 double mins = argc >= 5 ? argv[4].
toNumber() : 0;
781 double secs = argc >= 6 ? argv[5].
toNumber() : 0;
782 double ms = argc >= 7 ? argv[6].
toNumber() : 0;
783 if (year >= 0 && year <= 99)
794 obj->setProtoFromNewTarget(newTarget);
795 return obj->asReturnedValue();
802 return e->newString(
ToString(
t,
e->localTZA))->asReturnedValue();
818 defineDefaultProperty(
engine->id_toString(), method_toString, 0);
819 defineDefaultProperty(
QStringLiteral(
"toDateString"), method_toDateString, 0);
820 defineDefaultProperty(
QStringLiteral(
"toTimeString"), method_toTimeString, 0);
821 defineDefaultProperty(
engine->id_toLocaleString(), method_toLocaleString, 0);
822 defineDefaultProperty(
QStringLiteral(
"toLocaleDateString"), method_toLocaleDateString, 0);
823 defineDefaultProperty(
QStringLiteral(
"toLocaleTimeString"), method_toLocaleTimeString, 0);
824 defineDefaultProperty(
engine->id_valueOf(), method_valueOf, 0);
825 defineDefaultProperty(
QStringLiteral(
"getTime"), method_getTime, 0);
826 defineDefaultProperty(
QStringLiteral(
"getYear"), method_getYear, 0);
827 defineDefaultProperty(
QStringLiteral(
"getFullYear"), method_getFullYear, 0);
828 defineDefaultProperty(
QStringLiteral(
"getUTCFullYear"), method_getUTCFullYear, 0);
829 defineDefaultProperty(
QStringLiteral(
"getMonth"), method_getMonth, 0);
830 defineDefaultProperty(
QStringLiteral(
"getUTCMonth"), method_getUTCMonth, 0);
831 defineDefaultProperty(
QStringLiteral(
"getDate"), method_getDate, 0);
832 defineDefaultProperty(
QStringLiteral(
"getUTCDate"), method_getUTCDate, 0);
833 defineDefaultProperty(
QStringLiteral(
"getDay"), method_getDay, 0);
834 defineDefaultProperty(
QStringLiteral(
"getUTCDay"), method_getUTCDay, 0);
835 defineDefaultProperty(
QStringLiteral(
"getHours"), method_getHours, 0);
836 defineDefaultProperty(
QStringLiteral(
"getUTCHours"), method_getUTCHours, 0);
837 defineDefaultProperty(
QStringLiteral(
"getMinutes"), method_getMinutes, 0);
838 defineDefaultProperty(
QStringLiteral(
"getUTCMinutes"), method_getUTCMinutes, 0);
839 defineDefaultProperty(
QStringLiteral(
"getSeconds"), method_getSeconds, 0);
840 defineDefaultProperty(
QStringLiteral(
"getUTCSeconds"), method_getUTCSeconds, 0);
841 defineDefaultProperty(
QStringLiteral(
"getMilliseconds"), method_getMilliseconds, 0);
842 defineDefaultProperty(
QStringLiteral(
"getUTCMilliseconds"), method_getUTCMilliseconds, 0);
843 defineDefaultProperty(
QStringLiteral(
"getTimezoneOffset"), method_getTimezoneOffset, 0);
844 defineDefaultProperty(
QStringLiteral(
"setTime"), method_setTime, 1);
845 defineDefaultProperty(
QStringLiteral(
"setMilliseconds"), method_setMilliseconds, 1);
846 defineDefaultProperty(
QStringLiteral(
"setUTCMilliseconds"), method_setUTCMilliseconds, 1);
847 defineDefaultProperty(
QStringLiteral(
"setSeconds"), method_setSeconds, 2);
848 defineDefaultProperty(
QStringLiteral(
"setUTCSeconds"), method_setUTCSeconds, 2);
849 defineDefaultProperty(
QStringLiteral(
"setMinutes"), method_setMinutes, 3);
850 defineDefaultProperty(
QStringLiteral(
"setUTCMinutes"), method_setUTCMinutes, 3);
851 defineDefaultProperty(
QStringLiteral(
"setHours"), method_setHours, 4);
852 defineDefaultProperty(
QStringLiteral(
"setUTCHours"), method_setUTCHours, 4);
853 defineDefaultProperty(
QStringLiteral(
"setDate"), method_setDate, 1);
854 defineDefaultProperty(
QStringLiteral(
"setUTCDate"), method_setUTCDate, 1);
855 defineDefaultProperty(
QStringLiteral(
"setMonth"), method_setMonth, 2);
856 defineDefaultProperty(
QStringLiteral(
"setUTCMonth"), method_setUTCMonth, 2);
857 defineDefaultProperty(
QStringLiteral(
"setYear"), method_setYear, 1);
858 defineDefaultProperty(
QStringLiteral(
"setFullYear"), method_setFullYear, 3);
859 defineDefaultProperty(
QStringLiteral(
"setUTCFullYear"), method_setUTCFullYear, 3);
869 defineDefaultProperty(us, toUtcGmtStringFn);
870 defineDefaultProperty(gs, toUtcGmtStringFn);
873 defineDefaultProperty(
QStringLiteral(
"toISOString"), method_toISOString, 0);
874 defineDefaultProperty(
QStringLiteral(
"toJSON"), method_toJSON, 1);
896 const int numArgs = argc;
903 double month = numArgs >= 2 ? argv[1].
toNumber() : 0;
906 double day = numArgs >= 3 ? argv[2].
toNumber() : 1;
909 double hours = numArgs >= 4 ? argv[3].
toNumber() : 0;
912 double mins = numArgs >= 5 ? argv[4].
toNumber() : 0;
915 double secs = numArgs >= 6 ? argv[5].
toNumber() : 0;
918 double ms = numArgs >= 7 ? argv[6].
toNumber() : 0;
922 if (!
qIsNaN(year) && iyear >= 0 && iyear <= 99)
937 double t = getThisDate(v4, thisObject);
944 double t = getThisDate(v4, thisObject);
951 double t = getThisDate(v4, thisObject);
958 double t = getThisDate(v4, thisObject);
965 double t = getThisDate(v4, thisObject);
972 double t = getThisDate(v4, thisObject);
979 double t = getThisDate(v4, thisObject);
986 double t = getThisDate(v4, thisObject);
993 double t = getThisDate(v4, thisObject);
1002 double t = getThisDate(v4, thisObject);
1011 double t = getThisDate(v4, thisObject);
1020 double t = getThisDate(v4, thisObject);
1029 double t = getThisDate(v4, thisObject);
1038 double t = getThisDate(v4, thisObject);
1047 double t = getThisDate(v4, thisObject);
1056 double t = getThisDate(v4, thisObject);
1065 double t = getThisDate(v4, thisObject);
1074 double t = getThisDate(v4, thisObject);
1083 double t = getThisDate(v4, thisObject);
1092 double t = getThisDate(v4, thisObject);
1101 double t = getThisDate(v4, thisObject);
1110 double t = getThisDate(v4, thisObject);
1119 double t = getThisDate(v4, thisObject);
1128 double t = getThisDate(v4, thisObject);
1137 double t = getThisDate(v4, thisObject);
1146 double t = getThisDate(v4, thisObject);
1163 return Encode(self->date());
1180 return Encode(self->date());
1190 double t = self->date();
1197 return Encode(self->date());
1218 return Encode(self->date());
1228 double t = self->date();
1233 return Encode(self->date());
1257 return Encode(self->date());
1267 double t = self->date();
1273 return Encode(self->date());
1300 return Encode(self->date());
1310 double t = self->date();
1317 return Encode(self->date());
1335 return Encode(self->date());
1345 double t = self->date();
1353 return Encode(self->date());
1374 return Encode(self->date());
1384 double t = self->date();
1389 return Encode(self->date());
1399 double t = self->date();
1406 if (std::isnan(year)) {
1415 return Encode(self->date());
1425 double t = self->date();
1431 return Encode(self->date());
1457 return Encode(self->date());
1467 double t = self->date();
1491 double t = self->date();
1492 if (!std::isfinite(
t))
1497 if (year < 0 || year > 9999) {
1498 if (
qAbs(year) >= 1000000)
1550 return e->throwTypeError();
1554 if (
id ==
e->id_default()->propertyKey())
1555 hint =
e->id_string();
1556 else if (
id !=
e->id_string()->propertyKey() &&
id !=
e->id_number()->propertyKey())
1557 return e->throwTypeError();
\inmodule QtCore\reentrant
qint64 toMSecsSinceEpoch() const
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
QDateTime toTimeZone(const QTimeZone &toZone) const
QDateTime toUTC() const
Returns a copy of this datetime converted to UTC.
QTime time() const
Returns the time part of the datetime.
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
static QDateTime currentDateTimeUtc()
QDate date() const
Returns the date part of the datetime.
\inmodule QtCore \reentrant
QDateTime startOfDay(const QTimeZone &zone) const
QString toString(qlonglong i) const
Returns a localized string representation of i.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const
Returns the number of characters in this string.
QChar * data()
Returns a pointer to the data stored in the QString.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
void resize(qsizetype size)
Sets the size of the string to size characters.
\inmodule QtCore \reentrant
int hour() const
Returns the hour part (0 to 23) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
bool isValid() const
Returns true if the time is valid; otherwise returns false.
int msec() const
Returns the millisecond part (0 to 999) of the time.
int second() const
Returns the second part (0 to 59) of the time.
int getCurrentStandardUtcOffset()
int getUtcOffset(qint64 atMSecsSinceEpoch)
\qmltype Particle \inqmlmodule QtQuick.Particles
ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result)
@ Attr_ReadOnly_ButConfigurable
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qIsFinite(qfloat16 f) noexcept
bool qIsNaN(qfloat16 f) noexcept
constexpr T qAbs(const T &t)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qQNaN()
constexpr static Q_DECL_CONST_FUNCTION double qt_qnan() noexcept
static Q_DECL_CONST_FUNCTION bool qt_is_finite(double d)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
unsigned long long quint64
static const double msPerHour
static const double msPerDay
static bool InLeapYear(double t)
static double DayFromYear(double y)
static QString ToString(double t, double localTZA)
static double UTC(double t, double localTZA)
static double ParseString(const QString &s, double localTZA)
static QString ToUTCString(double t)
static const double MinutesPerHour
static int msFromTime(double t)
static double DaysInYear(double y)
static const double msPerSecond
static QString ToLocaleTimeString(double t)
static double YearFromTime(double t)
static QDateTime ToDateTime(double t, QTimeZone zone)
static QString ToTimeString(double t)
static const double msPerMinute
static double getLocalTZA()
static double TimeWithinDay(double t)
static double TimeFromYear(double y)
static QString ToLocaleDateString(double t)
static double DayFromMonth(double month, double leap)
static double WeekDay(double t)
static double MakeDate(double day, double time)
static double MakeDay(double year, double month, double day)
static double DaylightSavingTA(double t, double localTZA)
static QString ToLocaleString(double t)
static double DayWithinYear(double t)
static void addZeroPrefixedInt(QString &str, int num, int nDigits)
static double MonthFromTime(double t)
static int HourFromTime(double t)
static int SecFromTime(double t)
static double Day(double t)
static double TimeClip(double t)
static int MinFromTime(double t)
static QString ToDateString(double t)
static double MakeTime(double hour, double min, double sec, double ms)
static const double SecondsPerMinute
static double DateFromTime(double t)
static double LocalTime(double t, double localTZA)
static const double HoursPerDay
static double currentTime()
#define DEFINE_OBJECT_VTABLE(classname)
\inmodule QtCore \reentrant
static QDate dateTimeToDate(const QDateTime &dateTime)
static QString dateTimeToString(const QDateTime &dateTime, ExecutionEngine *engine)
static QDateTime stringToDateTime(const QString &string, ExecutionEngine *engine)
Q_QML_PRIVATE_EXPORT QDateTime toQDateTime() const
static ReturnedValue method_setMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_UTC(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toTimeString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setUTCHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setUTCMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getTimezoneOffset(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toLocaleDateString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setUTCSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getDay(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toLocaleTimeString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCDay(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setTime(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toISOString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setUTCMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static void timezoneUpdated(ExecutionEngine *e)
static ReturnedValue method_setUTCFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toDateString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_symbolToPrimitive(const FunctionObject *f, const Value *thisObject, const Value *, int)
static ReturnedValue method_getTime(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_parse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toJSON(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toUTCString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setUTCDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUTCFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_now(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setUTCMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static double getThisDate(ExecutionEngine *v4, const Value *thisObject)
static ReturnedValue method_setSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
QVariant toVariant() const
static constexpr quint64 MaxDateVal
QDateTime toQDateTime() const
static constexpr ReturnedValue undefined()
static constexpr ReturnedValue null()
Heap::String * newString(const QString &s=QString())
Heap::DateObject * newDateObject(double dateTime)
ReturnedValue throwRangeError(const Value &value)
ReturnedValue throwTypeError()
static Heap::FunctionObject * createBuiltinFunction(ExecutionEngine *engine, StringOrSymbol *nameOrSymbol, VTable::Call code, int argumentCount)
ReturnedValue call(const JSCallData &data) const
Heap::ExecutionContext * scope() const
void init(QV4::ExecutionContext *scope)
ExecutionEngine * engine() const
void defineDefaultProperty(StringOrSymbol *name, const Value &value, PropertyAttributes attributes=Attr_Data|Attr_NotEnumerable)
void defineReadonlyConfigurableProperty(const QString &name, const Value &value)
void defineReadonlyProperty(const QString &name, const Value &value)
static ReturnedValue ordinaryToPrimitive(ExecutionEngine *engine, const Object *object, String *typeHint)
static ReturnedValue toPrimitive(const Value &value, TypeHint typeHint)
static constexpr VTable::CallAsConstructor virtualCallAsConstructor
static constexpr VTable::Call virtualCall
static constexpr Value fromInt32(int i)
QML_NEARLY_ALWAYS_INLINE String * stringValue() const
Heap::Object * toObject(ExecutionEngine *e) const