diff options
Diffstat (limited to 'src/script/utils/qscriptdate.cpp')
-rw-r--r-- | src/script/utils/qscriptdate.cpp | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/src/script/utils/qscriptdate.cpp b/src/script/utils/qscriptdate.cpp index 5e8a771..f0b6172 100644 --- a/src/script/utils/qscriptdate.cpp +++ b/src/script/utils/qscriptdate.cpp @@ -304,25 +304,6 @@ static inline qsreal UTC(qsreal t) return t - LocalTZA - DaylightSavingTA(t - LocalTZA); } -static inline qsreal currentTime() -{ -#ifndef Q_WS_WIN - struct timeval tv; - - gettimeofday(&tv, 0); - return ::floor(tv.tv_sec * msPerSecond + (tv.tv_usec / 1000.0)); -#else - SYSTEMTIME st; - GetSystemTime(&st); - FILETIME ft; - SystemTimeToFileTime(&st, &ft); - LARGE_INTEGER li; - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; - return double(li.QuadPart - Q_INT64_C(116444736000000000)) / 10000.0; -#endif -} - static inline qsreal TimeClip(qsreal t) { if (! qIsFinite(t) || fabs(t) > 8.64e15) @@ -330,121 +311,6 @@ static inline qsreal TimeClip(qsreal t) return ToInteger(t); } -static inline qsreal ParseString(const QString &s) -{ - QDateTime dt = QDateTime::fromString(s, Qt::TextDate); - if (!dt.isValid()) - dt = QDateTime::fromString(s, Qt::ISODate); - if (!dt.isValid()) { - QStringList formats; - formats << QLatin1String("M/d/yyyy") - << QLatin1String("M/d/yyyy hh:mm") - << QLatin1String("M/d/yyyy hh:mm A") - - << QLatin1String("M/d/yyyy, hh:mm") - << QLatin1String("M/d/yyyy, hh:mm A") - - << QLatin1String("MMM d yyyy") - << QLatin1String("MMM d yyyy hh:mm") - << QLatin1String("MMM d yyyy hh:mm:ss") - << QLatin1String("MMM d yyyy, hh:mm") - << QLatin1String("MMM d yyyy, hh:mm:ss") - - << QLatin1String("MMMM d yyyy") - << QLatin1String("MMMM d yyyy hh:mm") - << QLatin1String("MMMM d yyyy hh:mm:ss") - << QLatin1String("MMMM d yyyy, hh:mm") - << QLatin1String("MMMM d yyyy, hh:mm:ss") - - << QLatin1String("MMM d, yyyy") - << QLatin1String("MMM d, yyyy hh:mm") - << QLatin1String("MMM d, yyyy hh:mm:ss") - - << QLatin1String("MMMM d, yyyy") - << QLatin1String("MMMM d, yyyy hh:mm") - << QLatin1String("MMMM d, yyyy hh:mm:ss") - - << QLatin1String("d MMM yyyy") - << QLatin1String("d MMM yyyy hh:mm") - << QLatin1String("d MMM yyyy hh:mm:ss") - << QLatin1String("d MMM yyyy, hh:mm") - << QLatin1String("d MMM yyyy, hh:mm:ss") - - << QLatin1String("d MMMM yyyy") - << QLatin1String("d MMMM yyyy hh:mm") - << QLatin1String("d MMMM yyyy hh:mm:ss") - << QLatin1String("d MMMM yyyy, hh:mm") - << QLatin1String("d MMMM yyyy, hh:mm:ss") - - << QLatin1String("d MMM, yyyy") - << QLatin1String("d MMM, yyyy hh:mm") - << QLatin1String("d MMM, yyyy hh:mm:ss") - - << QLatin1String("d MMMM, yyyy") - << QLatin1String("d MMMM, yyyy hh:mm") - << QLatin1String("d MMMM, yyyy hh:mm:ss"); - - for (int i = 0; i < formats.size(); ++i) { - dt = QDateTime::fromString(s, formats.at(i)); - if (dt.isValid()) - break; - } - } - return FromDateTime(dt); -} - -static inline QString ToString(qsreal t) -{ - if (qIsNaN(t)) - return QLatin1String("Invalid Date"); - QString str = ToDateTime(t, Qt::LocalTime).toString() + QLatin1String(" GMT"); - qsreal tzoffset = LocalTZA + DaylightSavingTA(t); - if (tzoffset) { - int hours = tzoffset / 1000 / 60 / 60; - int mins = int(tzoffset / 1000 / 60) % 60; - str.append(QLatin1Char((tzoffset > 0) ? '+' : '-')); - if (hours < 10) - str.append(QLatin1Char('0')); - str.append(QString::number(hours)); - if (mins < 10) - str.append(QLatin1Char('0')); - str.append(QString::number(mins)); - } - return str; -} - -static inline QString ToUTCString(qsreal t) -{ - if (qIsNaN(t)) - return QLatin1String("Invalid Date"); - return ToDateTime(t, Qt::UTC).toString() + QLatin1String(" GMT"); -} - -static inline QString ToDateString(qsreal t) -{ - return ToDateTime(t, Qt::LocalTime).date().toString(); -} - -static inline QString ToTimeString(qsreal t) -{ - return ToDateTime(t, Qt::LocalTime).time().toString(); -} - -static inline QString ToLocaleString(qsreal t) -{ - return ToDateTime(t, Qt::LocalTime).toString(Qt::LocaleDate); -} - -static inline QString ToLocaleDateString(qsreal t) -{ - return ToDateTime(t, Qt::LocalTime).date().toString(Qt::LocaleDate); -} - -static inline QString ToLocaleTimeString(qsreal t) -{ - return ToDateTime(t, Qt::LocalTime).time().toString(Qt::LocaleDate); -} - static qsreal getLocalTZA() { #ifndef Q_WS_WIN |