Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qv4dateobject.cpp File Reference

(8b6a9403bf2e04d34b9b07d2780186029fab99d0)

#include "qv4dateobject_p.h"
#include "qv4runtime_p.h"
#include "qv4symbol_p.h"
#include <QtCore/QDebug>
#include <QtCore/QDateTime>
#include <QtCore/private/qlocaltime_p.h>
#include <QtCore/QStringList>
#include <QtCore/QTimeZone>
#include <wtf/MathExtras.h>
+ Include dependency graph for qv4dateobject.cpp:

Go to the source code of this file.

Functions

static double TimeWithinDay (double t)
 
static int HourFromTime (double t)
 
static int MinFromTime (double t)
 
static int SecFromTime (double t)
 
static int msFromTime (double t)
 
static double Day (double t)
 
static double DaysInYear (double y)
 
static double DayFromYear (double y)
 
static double TimeFromYear (double y)
 
static double YearFromTime (double t)
 
static bool InLeapYear (double t)
 
static double DayWithinYear (double t)
 
static double MonthFromTime (double t)
 
static double DateFromTime (double t)
 
static double WeekDay (double t)
 
static double MakeTime (double hour, double min, double sec, double ms)
 
static double DayFromMonth (double month, double leap)
 
static double MakeDay (double year, double month, double day)
 
static double MakeDate (double day, double time)
 
static double DaylightSavingTA (double t, double localTZA)
 
static double LocalTime (double t, double localTZA)
 
static double UTC (double t, double localTZA)
 
static double currentTime ()
 
static double TimeClip (double t)
 
static double ParseString (const QString &s, double localTZA)
 
static QDateTime ToDateTime (double t, QTimeZone zone)
 
static QString ToString (double t, double localTZA)
 
static QString ToUTCString (double t)
 
static QString ToDateString (double t)
 
static QString ToTimeString (double t)
 
static QString ToLocaleString (double t)
 
static QString ToLocaleDateString (double t)
 
static QString ToLocaleTimeString (double t)
 
static double getLocalTZA ()
 
 DEFINE_OBJECT_VTABLE (DateObject)
 
 DEFINE_OBJECT_VTABLE (DateCtor)
 
static void addZeroPrefixedInt (QString &str, int num, int nDigits)
 

Variables

static const double HoursPerDay = 24.0
 
static const double MinutesPerHour = 60.0
 
static const double SecondsPerMinute = 60.0
 
static const double msPerSecond = 1000.0
 
static const double msPerMinute = 60000.0
 
static const double msPerHour = 3600000.0
 
static const double msPerDay = 86400000.0
 

Function Documentation

◆ addZeroPrefixedInt()

static void addZeroPrefixedInt ( QString & str,
int num,
int nDigits )
static

Definition at line 1490 of file qv4dateobject.cpp.

References QString::data(), QString::resize(), QString::size(), and str.

Referenced by QV4::DatePrototype::method_toISOString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentTime()

◆ DateFromTime()

static double DateFromTime ( double t)
inlinestatic

Definition at line 156 of file qv4dateobject.cpp.

References d, DayWithinYear(), InLeapYear(), MonthFromTime(), qt_qnan(), and QV4::Value::toInteger().

Referenced by MakeDay(), QV4::DatePrototype::method_getDate(), QV4::DatePrototype::method_getUTCDate(), QV4::DatePrototype::method_setFullYear(), QV4::DatePrototype::method_setMonth(), QV4::DatePrototype::method_setUTCFullYear(), QV4::DatePrototype::method_setUTCMonth(), QV4::DatePrototype::method_setYear(), and QV4::DatePrototype::method_toISOString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Day()

◆ DayFromMonth()

static double DayFromMonth ( double month,
double leap )
inlinestatic

Definition at line 198 of file qv4dateobject.cpp.

References qt_qnan().

Referenced by MakeDay().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DayFromYear()

static double DayFromYear ( double y)
inlinestatic

Definition at line 75 of file qv4dateobject.cpp.

Referenced by DayWithinYear(), MakeDay(), and TimeFromYear().

+ Here is the caller graph for this function:

◆ DaylightSavingTA()

static double DaylightSavingTA ( double t,
double localTZA )
inlinestatic

Definition at line 278 of file qv4dateobject.cpp.

References QLocalTime::getUtcOffset().

Referenced by LocalTime(), ToString(), and UTC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DaysInYear()

static double DaysInYear ( double y)
inlinestatic

Definition at line 61 of file qv4dateobject.cpp.

Referenced by InLeapYear(), and YearFromTime().

+ Here is the caller graph for this function:

◆ DayWithinYear()

static double DayWithinYear ( double t)
inlinestatic

Definition at line 107 of file qv4dateobject.cpp.

References Day(), DayFromYear(), and YearFromTime().

Referenced by DateFromTime(), and MonthFromTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DEFINE_OBJECT_VTABLE() [1/2]

DEFINE_OBJECT_VTABLE ( DateCtor )

◆ DEFINE_OBJECT_VTABLE() [2/2]

DEFINE_OBJECT_VTABLE ( DateObject )

◆ getLocalTZA()

static double getLocalTZA ( )
static

Definition at line 610 of file qv4dateobject.cpp.

References QLocalTime::getCurrentStandardUtcOffset().

Referenced by QV4::DatePrototype::init(), and QV4::DatePrototype::timezoneUpdated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HourFromTime()

static int HourFromTime ( double t)
inlinestatic

◆ InLeapYear()

static bool InLeapYear ( double t)
inlinestatic

Definition at line 97 of file qv4dateobject.cpp.

References DaysInYear(), Q_ASSERT, and YearFromTime().

Referenced by DateFromTime(), MakeDay(), and MonthFromTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LocalTime()

◆ MakeDate()

◆ MakeDay()

static double MakeDay ( double year,
double month,
double day )
static

Definition at line 218 of file qv4dateobject.cpp.

References DateFromTime(), Day(), DayFromMonth(), DayFromYear(), InLeapYear(), MonthFromTime(), msPerDay, Q_ASSERT, qIsFinite(), qQNaN(), qt_qnan(), qWarning, QV4::Value::toInteger(), and YearFromTime().

Referenced by QV4::DateObject::componentsToTimestamp(), QV4::Date::init(), QV4::DatePrototype::method_setDate(), QV4::DatePrototype::method_setFullYear(), QV4::DatePrototype::method_setMonth(), QV4::DatePrototype::method_setUTCDate(), QV4::DatePrototype::method_setUTCFullYear(), QV4::DatePrototype::method_setUTCMonth(), QV4::DatePrototype::method_setYear(), QV4::DatePrototype::method_UTC(), and ParseString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeTime()

static double MakeTime ( double hour,
double min,
double sec,
double ms )
inlinestatic

Definition at line 187 of file qv4dateobject.cpp.

References MinutesPerHour, msPerSecond, qIsFinite(), qQNaN(), SecondsPerMinute, and QV4::Value::toInteger().

Referenced by QV4::DateObject::componentsToTimestamp(), QV4::Date::init(), QV4::DatePrototype::method_setHours(), QV4::DatePrototype::method_setMilliseconds(), QV4::DatePrototype::method_setMinutes(), QV4::DatePrototype::method_setSeconds(), QV4::DatePrototype::method_setUTCHours(), QV4::DatePrototype::method_setUTCMilliseconds(), QV4::DatePrototype::method_setUTCMinutes(), QV4::DatePrototype::method_setUTCSeconds(), QV4::DatePrototype::method_UTC(), and ParseString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MinFromTime()

static int MinFromTime ( double t)
inlinestatic

◆ MonthFromTime()

static double MonthFromTime ( double t)
inlinestatic

Definition at line 112 of file qv4dateobject.cpp.

References d, DayWithinYear(), InLeapYear(), and qt_qnan().

Referenced by DateFromTime(), MakeDay(), QV4::DatePrototype::method_getMonth(), QV4::DatePrototype::method_getUTCMonth(), QV4::DatePrototype::method_setDate(), QV4::DatePrototype::method_setFullYear(), QV4::DatePrototype::method_setUTCDate(), QV4::DatePrototype::method_setUTCFullYear(), QV4::DatePrototype::method_setYear(), and QV4::DatePrototype::method_toISOString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msFromTime()

static int msFromTime ( double t)
inlinestatic

◆ ParseString()

static double ParseString ( const QString & s,
double localTZA )
inlinestatic

Definition at line 312 of file qv4dateobject.cpp.

References ch, Day(), error, Qt::ISODate, MakeDate(), MakeDay(), MakeTime(), Q_ASSERT, QStringLiteral, qt_qnan(), Qt::RFC2822Date, Qt::TextDate, TimeClip(), QTimeZone::UTC, and UTC().

Referenced by QV4::DatePrototype::method_parse(), QV4::DateObject::stringToDateTime(), and QV4::DateCtor::virtualCallAsConstructor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SecFromTime()

◆ TimeClip()

static double TimeClip ( double t)
inlinestatic

Definition at line 303 of file qv4dateobject.cpp.

References QV4::Date::MaxDateVal, qt_is_finite(), qt_qnan(), and QV4::Value::toInteger().

Referenced by QV4::DateObject::dateTimeToNumber(), QV4::DateObject::dateTimeToString(), QV4::DatePrototype::method_UTC(), and ParseString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TimeFromYear()

static double TimeFromYear ( double y)
inlinestatic

Definition at line 83 of file qv4dateobject.cpp.

References DayFromYear(), and msPerDay.

Referenced by YearFromTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TimeWithinDay()

static double TimeWithinDay ( double t)
inlinestatic

Definition at line 26 of file qv4dateobject.cpp.

References msPerDay.

Referenced by QV4::DatePrototype::method_setDate(), QV4::DatePrototype::method_setFullYear(), QV4::DatePrototype::method_setMonth(), QV4::DatePrototype::method_setUTCDate(), QV4::DatePrototype::method_setUTCFullYear(), QV4::DatePrototype::method_setUTCMonth(), and QV4::DatePrototype::method_setYear().

+ Here is the caller graph for this function:

◆ ToDateString()

static QString ToDateString ( double t)
inlinestatic

Definition at line 585 of file qv4dateobject.cpp.

References QTimeZone::LocalTime, and ToDateTime().

Referenced by QV4::DatePrototype::method_toDateString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToDateTime()

static QDateTime ToDateTime ( double t,
QTimeZone zone )
inlinestatic

Converts the ECMA Date value t (in UTC form) to QDateTime according to spec.

Definition at line 551 of file qv4dateobject.cpp.

References QDateTime::fromMSecsSinceEpoch(), and QDateTime::toTimeZone().

Referenced by QV4::DateObject::stringToDateTime(), QV4::DateObject::timestampToDateTime(), ToDateString(), ToLocaleDateString(), ToLocaleString(), ToLocaleTimeString(), QV4::Date::toQDateTime(), ToString(), ToTimeString(), and ToUTCString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToLocaleDateString()

static QString ToLocaleDateString ( double t)
inlinestatic

Definition at line 600 of file qv4dateobject.cpp.

References date, QTimeZone::LocalTime, QLocale::ShortFormat, ToDateTime(), and QLocale::toString().

Referenced by QV4::DatePrototype::method_toLocaleDateString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToLocaleString()

static QString ToLocaleString ( double t)
inlinestatic

Definition at line 595 of file qv4dateobject.cpp.

References QTimeZone::LocalTime, QLocale::ShortFormat, ToDateTime(), and QLocale::toString().

Referenced by QV4::DatePrototype::method_toLocaleString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToLocaleTimeString()

static QString ToLocaleTimeString ( double t)
inlinestatic

Definition at line 605 of file qv4dateobject.cpp.

References QTimeZone::LocalTime, QLocale::ShortFormat, time, ToDateTime(), and QLocale::toString().

Referenced by QV4::DatePrototype::method_toLocaleTimeString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToString()

static QString ToString ( double t,
double localTZA )
inlinestatic

Definition at line 558 of file qv4dateobject.cpp.

References QString::append(), DaylightSavingTA(), QTimeZone::LocalTime, QString::number(), QStringLiteral, str, and ToDateTime().

Referenced by QV4::DateObject::dateTimeToString(), QV4::DatePrototype::method_toString(), QV4::DateObject::toString(), and QV4::DateCtor::virtualCall().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToTimeString()

static QString ToTimeString ( double t)
inlinestatic

Definition at line 590 of file qv4dateobject.cpp.

References QTimeZone::LocalTime, and ToDateTime().

Referenced by QV4::DatePrototype::method_toTimeString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToUTCString()

static QString ToUTCString ( double t)
inlinestatic

Definition at line 578 of file qv4dateobject.cpp.

References QStringLiteral, ToDateTime(), and QTimeZone::UTC.

Referenced by QV4::DatePrototype::method_toUTCString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UTC()

static double UTC ( double t,
double localTZA )
inlinestatic

Definition at line 292 of file qv4dateobject.cpp.

References DaylightSavingTA().

Referenced by QV4::DateObject::componentsToTimestamp(), QV4::Date::init(), QV4::DatePrototype::method_setDate(), QV4::DatePrototype::method_setFullYear(), QV4::DatePrototype::method_setHours(), QV4::DatePrototype::method_setMilliseconds(), QV4::DatePrototype::method_setMinutes(), QV4::DatePrototype::method_setMonth(), QV4::DatePrototype::method_setSeconds(), QV4::DatePrototype::method_setYear(), and ParseString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WeekDay()

static double WeekDay ( double t)
inlinestatic

Definition at line 180 of file qv4dateobject.cpp.

References Day().

Referenced by QV4::DatePrototype::method_getDay(), QV4::DatePrototype::method_getUTCDay(), and QDateTimeParser::setDigit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ YearFromTime()

static double YearFromTime ( double t)
inlinestatic

Definition at line 88 of file qv4dateobject.cpp.

References DaysInYear(), msPerDay, t2, and TimeFromYear().

Referenced by DayWithinYear(), InLeapYear(), MakeDay(), QV4::DatePrototype::method_getFullYear(), QV4::DatePrototype::method_getUTCFullYear(), QV4::DatePrototype::method_getYear(), QV4::DatePrototype::method_setDate(), QV4::DatePrototype::method_setMonth(), QV4::DatePrototype::method_setUTCDate(), QV4::DatePrototype::method_setUTCMonth(), and QV4::DatePrototype::method_toISOString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ HoursPerDay

const double HoursPerDay = 24.0
static

Definition at line 18 of file qv4dateobject.cpp.

Referenced by HourFromTime().

◆ MinutesPerHour

const double MinutesPerHour = 60.0
static

Definition at line 19 of file qv4dateobject.cpp.

Referenced by MakeTime(), and MinFromTime().

◆ msPerDay

const double msPerDay = 86400000.0
static

Definition at line 24 of file qv4dateobject.cpp.

Referenced by Day(), MakeDate(), MakeDay(), TimeFromYear(), TimeWithinDay(), and YearFromTime().

◆ msPerHour

const double msPerHour = 3600000.0
static

Definition at line 23 of file qv4dateobject.cpp.

Referenced by HourFromTime().

◆ msPerMinute

const double msPerMinute = 60000.0
static

Definition at line 22 of file qv4dateobject.cpp.

Referenced by QV4::DatePrototype::method_getTimezoneOffset(), and MinFromTime().

◆ msPerSecond

const double msPerSecond = 1000.0
static

Definition at line 21 of file qv4dateobject.cpp.

Referenced by MakeTime(), msFromTime(), and SecFromTime().

◆ SecondsPerMinute

const double SecondsPerMinute = 60.0
static

Definition at line 20 of file qv4dateobject.cpp.

Referenced by MakeTime(), and SecFromTime().