summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/configure.json6
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h1
-rw-r--r--src/corelib/tools/qdatetime.cpp80
-rw-r--r--src/corelib/tools/qdatetime.h18
-rw-r--r--src/corelib/tools/qdatetime_p.h14
-rw-r--r--src/corelib/tools/qtimezone.h2
-rw-r--r--src/corelib/tools/tools.pri39
7 files changed, 91 insertions, 69 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index d0a3a13e48..b911e08b64 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -564,6 +564,12 @@
"purpose": "Optimizes SHA3 for speed instead of size.",
"section": "Utilities",
"output": [ "privateFeature" ]
+ },
+ "timezone": {
+ "label": "QTimeZone",
+ "purpose": "Provides support for timezone handling.",
+ "section": "Utilities",
+ "output": [ "publicFeature" ]
}
},
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index 38b0cf2abf..f482c6b8f6 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -73,6 +73,7 @@
#define QT_NO_QOBJECT
#define QT_NO_SYSTEMLOCALE
#define QT_NO_THREAD
+#define QT_FEATURE_timezone -1
#define QT_NO_TRANSLATION
#define QT_FEATURE_translation -1
#define QT_NO_GEOM_VARIANT
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index f8611b3e68..7819d2e207 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -46,7 +46,9 @@
#include "qset.h"
#include "qlocale.h"
#include "qdatetime.h"
+#if QT_CONFIG(timezone)
#include "qtimezoneprivate_p.h"
+#endif
#include "qregexp.h"
#include "qdebug.h"
#ifndef Q_OS_WIN
@@ -1328,7 +1330,7 @@ QDate QDate::fromString(const QString& string, Qt::DateFormat format)
QDate QDate::fromString(const QString &string, const QString &format)
{
QDate date;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);
if (dt.parseFormat(format))
dt.fromString(string, &date, 0);
@@ -2016,7 +2018,7 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format)
QTime QTime::fromString(const QString &string, const QString &format)
{
QTime time;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);
if (dt.parseFormat(format))
dt.fromString(string, 0, &time);
@@ -2574,7 +2576,7 @@ static void refreshDateTime(QDateTimeData &d)
QTime testTime;
Q_ASSERT(spec == Qt::TimeZone || spec == Qt::LocalTime);
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
// If not valid time zone then is invalid
if (spec == Qt::TimeZone) {
if (!d->m_timeZone.isValid())
@@ -2582,7 +2584,7 @@ static void refreshDateTime(QDateTimeData &d)
else
epochMSecs = QDateTimePrivate::zoneMSecsToEpochMSecs(msecs, d->m_timeZone, &testDate, &testTime);
}
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
// If not valid date and time then is invalid
if (!(status & QDateTimePrivate::ValidDate) || !(status & QDateTimePrivate::ValidTime)) {
@@ -2674,9 +2676,9 @@ static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds)
d.detach();
d->m_status = status & ~QDateTimePrivate::ShortData;
d->m_offsetFromUtc = offsetSeconds;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
d->m_timeZone = QTimeZone();
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
}
}
@@ -2887,7 +2889,7 @@ QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTim
return result;
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
inline QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime,
const QTimeZone &toTimeZone)
{
@@ -2916,7 +2918,7 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT
return zoneMSecs - (data.standardTimeOffset * 1000);
}
}
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
/*****************************************************************************
QDateTime member functions
@@ -3110,7 +3112,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, in
{
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
/*!
\since 5.2
@@ -3126,7 +3128,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &time
: d(QDateTimePrivate::create(date, time, timeZone))
{
}
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
/*!
Constructs a copy of the \a other datetime.
@@ -3246,7 +3248,7 @@ Qt::TimeSpec QDateTime::timeSpec() const
return getSpec(d);
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
/*!
\since 5.2
@@ -3274,7 +3276,7 @@ QTimeZone QDateTime::timeZone() const
}
return QTimeZone();
}
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
/*!
\since 5.2
@@ -3337,15 +3339,15 @@ QString QDateTime::timeZoneAbbreviation() const
{
switch (getSpec(d)) {
case Qt::UTC:
- return QTimeZonePrivate::utcQString();
+ return QLatin1String("UTC");
case Qt::OffsetFromUTC:
- return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
+ return QLatin1String("UTC") + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
case Qt::TimeZone:
-#ifdef QT_BOOTSTRAPPED
+#if !QT_CONFIG(timezone)
break;
#else
return d->m_timeZone.d->abbreviation(toMSecsSinceEpoch());
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
case Qt::LocalTime: {
QString abbrev;
auto status = extractDaylightStatus(getStatus(d));
@@ -3374,11 +3376,11 @@ bool QDateTime::isDaylightTime() const
case Qt::OffsetFromUTC:
return false;
case Qt::TimeZone:
-#ifdef QT_BOOTSTRAPPED
+#if !QT_CONFIG(timezone)
break;
#else
return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
case Qt::LocalTime: {
auto status = extractDaylightStatus(getStatus(d));
if (status == QDateTimePrivate::UnknownDaylightTime)
@@ -3462,7 +3464,7 @@ void QDateTime::setOffsetFromUtc(int offsetSeconds)
checkValidDateTime(d);
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
/*!
\since 5.2
@@ -3482,7 +3484,7 @@ void QDateTime::setTimeZone(const QTimeZone &toZone)
d->m_timeZone = toZone;
refreshDateTime(d);
}
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
/*!
\since 4.7
@@ -3515,7 +3517,7 @@ qint64 QDateTime::toMSecsSinceEpoch() const
}
case Qt::TimeZone:
-#ifdef QT_BOOTSTRAPPED
+#if !QT_CONFIG(timezone)
return 0;
#else
return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone);
@@ -3613,7 +3615,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
break;
case Qt::TimeZone:
Q_ASSERT(!d.isShort());
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
// but all affected times afterwards will have DST applied.
d.detach();
@@ -3626,7 +3628,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
break;
case Qt::LocalTime: {
QDate dt;
@@ -3903,10 +3905,10 @@ static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date,
if (spec == Qt::LocalTime) {
QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime;
localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time);
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
} else if (spec == Qt::TimeZone) {
QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), d->m_timeZone, date, time);
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
}
}
@@ -4166,7 +4168,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
return fromMSecsSinceEpoch(toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
/*!
\since 5.2
@@ -4188,7 +4190,7 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
return fromMSecsSinceEpoch(toMSecsSinceEpoch(), timeZone);
}
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
/*!
Returns \c true if this datetime is equal to the \a other datetime;
@@ -4447,7 +4449,7 @@ QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSecon
return fromMSecsSinceEpoch((qint64)seconds * 1000, spec, offsetSeconds);
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
/*!
\since 5.2
\deprecated
@@ -4540,7 +4542,7 @@ QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offs
return fromMSecsSinceEpoch(secs * 1000, spec, offsetSeconds);
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
/*!
\since 5.2
@@ -4929,7 +4931,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)
QDateTime QDateTime::fromString(const QString &string, const QString &format)
{
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QTime time;
QDate date;
@@ -5072,10 +5074,10 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
out << dateAndTime << qint8(dateTime.timeSpec());
if (dateTime.timeSpec() == Qt::OffsetFromUTC)
out << qint32(dateTime.offsetFromUtc());
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
else if (dateTime.timeSpec() == Qt::TimeZone)
out << dateTime.timeZone();
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
} else if (out.version() == QDataStream::Qt_5_0) {
@@ -5132,9 +5134,9 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)
qint8 ts = 0;
Qt::TimeSpec spec = Qt::LocalTime;
qint32 offset = 0;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QTimeZone tz;
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
if (in.version() >= QDataStream::Qt_5_2) {
@@ -5144,11 +5146,11 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)
if (spec == Qt::OffsetFromUTC) {
in >> offset;
dateTime = QDateTime(dt, tm, spec, offset);
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
} else if (spec == Qt::TimeZone) {
in >> tz;
dateTime = QDateTime(dt, tm, tz);
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
} else {
dateTime = QDateTime(dt, tm, spec);
}
@@ -5174,7 +5176,7 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)
break;
case QDateTimePrivate::TimeZone:
spec = Qt::TimeZone;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
// FIXME: need to use a different constructor !
#endif
break;
@@ -5231,9 +5233,9 @@ QDebug operator<<(QDebug dbg, const QDateTime &date)
dbg << ' ' << date.offsetFromUtc() << 's';
break;
case Qt::TimeZone:
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
dbg << ' ' << date.timeZone().id();
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
break;
case Qt::LocalTime:
break;
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index ebf9b45570..c7f14ed40a 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -253,9 +253,9 @@ public:
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
// ### Qt 6: Merge with above with default offsetSeconds = 0
QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds);
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone);
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
QDateTime(const QDateTime &other) Q_DECL_NOTHROW;
QDateTime(QDateTime &&other) Q_DECL_NOTHROW;
~QDateTime();
@@ -274,9 +274,9 @@ public:
QTime time() const;
Qt::TimeSpec timeSpec() const;
int offsetFromUtc() const;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QTimeZone timeZone() const;
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
QString timeZoneAbbreviation() const;
bool isDaylightTime() const;
@@ -287,9 +287,9 @@ public:
void setTime(const QTime &time);
void setTimeSpec(Qt::TimeSpec spec);
void setOffsetFromUtc(int offsetSeconds);
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
void setTimeZone(const QTimeZone &toZone);
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
void setMSecsSinceEpoch(qint64 msecs);
void setSecsSinceEpoch(qint64 secs);
@@ -307,9 +307,9 @@ public:
inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); }
inline QDateTime toUTC() const { return toTimeSpec(Qt::UTC); }
QDateTime toOffsetFromUtc(int offsetSeconds) const;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QDateTime toTimeZone(const QTimeZone &toZone) const;
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
qint64 daysTo(const QDateTime &) const;
qint64 secsTo(const QDateTime &) const;
@@ -348,7 +348,7 @@ public:
static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0);
static QDateTime fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spe = Qt::LocalTime, int offsetFromUtc = 0);
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone);
static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone);
#endif
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index 38a084b257..eb33dddbb7 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -58,7 +58,9 @@
#include "QtCore/qdatetime.h"
#include "QtCore/qpair.h"
+#if QT_CONFIG(timezone)
#include "qtimezone.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -118,22 +120,22 @@ public:
static QDateTime::Data create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
int offsetSeconds);
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
static QDateTime::Data create(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone);
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
qint64 m_msecs;
StatusFlags m_status;
int m_offsetFromUtc;
mutable QAtomicInt ref;
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
QTimeZone m_timeZone;
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(timezone)
static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone,
QDate *localDate = 0, QTime *localTime = 0);
-#endif // QT_BOOTSTRAPPED
+#endif // timezone
static inline qint64 minJd() { return QDate::minJd(); }
static inline qint64 maxJd() { return QDate::maxJd(); }
diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h
index db99f07f44..083f87f39f 100644
--- a/src/corelib/tools/qtimezone.h
+++ b/src/corelib/tools/qtimezone.h
@@ -45,6 +45,8 @@
#include <QtCore/qlocale.h>
#include <QtCore/qdatetime.h>
+QT_REQUIRE_CONFIG(timezone);
+
QT_BEGIN_NAMESPACE
class QTimeZonePrivate;
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index e3d89651e4..2a203df4b8 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -67,9 +67,6 @@ HEADERS += \
tools/qstringmatcher.h \
tools/qtextboundaryfinder.h \
tools/qtimeline.h \
- tools/qtimezone.h \
- tools/qtimezoneprivate_p.h \
- tools/qtimezoneprivate_data_p.h \
tools/qtools_p.h \
tools/qunicodetables_p.h \
tools/qunicodetools_p.h \
@@ -116,8 +113,6 @@ SOURCES += \
tools/qstringlist.cpp \
tools/qtextboundaryfinder.cpp \
tools/qtimeline.cpp \
- tools/qtimezone.cpp \
- tools/qtimezoneprivate.cpp \
tools/qunicodetools.cpp \
tools/qvector.cpp \
tools/qvsnprintf.cpp \
@@ -128,18 +123,13 @@ msvc: NO_PCH_SOURCES += tools/qvector_msvc.cpp
false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
!nacl:mac: {
- OBJECTIVE_SOURCES += tools/qlocale_mac.mm \
- tools/qtimezoneprivate_mac.mm \
-}
-else:android {
- SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_android.cpp
+ SOURCES += tools/qlocale_mac.mm
}
else:unix {
- SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp
+ SOURCES += tools/qlocale_unix.cpp
}
else:win32 {
- SOURCES += tools/qlocale_win.cpp \
- tools/qtimezoneprivate_win.cpp
+ SOURCES += tools/qlocale_win.cpp
winphone: LIBS_PRIVATE += -lWindowsPhoneGlobalizationUtil
winrt-*-msvc2013: LIBS += advapi32.lib
} else:integrity {
@@ -157,8 +147,7 @@ qtConfig(icu) {
include($$PWD/../../3rdparty/icu_dependency.pri)
SOURCES += tools/qlocale_icu.cpp \
- tools/qcollator_icu.cpp \
- tools/qtimezoneprivate_icu.cpp
+ tools/qcollator_icu.cpp
DEFINES += QT_USE_ICU
} else: win32 {
SOURCES += tools/qcollator_win.cpp
@@ -168,6 +157,26 @@ qtConfig(icu) {
SOURCES += tools/qcollator_posix.cpp
}
+qtConfig(timezone) {
+ HEADERS += \
+ tools/qtimezone.h \
+ tools/qtimezoneprivate_p.h \
+ tools/qtimezoneprivate_data_p.h
+ SOURCES += \
+ tools/qtimezone.cpp \
+ tools/qtimezoneprivate.cpp
+ !nacl:darwin: \
+ SOURCES += tools/qtimezoneprivate_mac.mm
+ else: android: \
+ SOURCES += tools/qtimezoneprivate_android.cpp
+ else: unix: \
+ SOURCES += tools/qtimezoneprivate_tz.cpp
+ else: win32: \
+ SOURCES += tools/qtimezoneprivate_win.cpp
+ qtConfig(icu): \
+ SOURCES += tools/qtimezoneprivate_icu.cpp
+}
+
qtConfig(regularexpression) {
include($$PWD/../../3rdparty/pcre_dependency.pri)