From 62b3720a207ef0c6cfafaa0ecc26dd3cbbf400d0 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 29 Jan 2024 14:50:40 +0100 Subject: [PATCH] Remove system locale dependency from timezone code that doesn't need it Various parts of QTimeZone's code were, for no immediately apparent reason, conditioned on !defined(QT_NO_SYSTEMLOCALE). All are in any case conditioned on feature timezone; and none had any obvious relationship with QLocale::system(). Assume this is a fossil left over from initial development of timezone support and purge. [ChangeLog][QtCore][QTimeZone] Some features are now available whenever feature timezone is enabled, that were previously dependent on system locale support. Change-Id: I7f2246e17ace22d2aecc9286295ae522ee2a0f5f Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_foundation.mm | 4 ++-- src/corelib/time/qtimezone.cpp | 29 +++++++------------------- src/corelib/time/qtimezone.h | 4 ++-- src/corelib/time/qtimezoneprivate.cpp | 7 +++++-- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm index cf15e24917c..a31040944f1 100644 --- a/src/corelib/kernel/qcore_foundation.mm +++ b/src/corelib/kernel/qcore_foundation.mm @@ -10,7 +10,7 @@ #include #include -#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE) +#if QT_CONFIG(timezone) #include #include #include @@ -466,7 +466,7 @@ NSDate *QDateTime::toNSDate() const // ---------------------------------------------------------------------------- -#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE) +#if QT_CONFIG(timezone) /*! \brief Constructs a new QTimeZone containing a copy of the CFTimeZone \a timeZone. diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp index c7cf18d346e..e4d17596d8e 100644 --- a/src/corelib/time/qtimezone.cpp +++ b/src/corelib/time/qtimezone.cpp @@ -22,13 +22,6 @@ using namespace Qt::StringLiterals; // Create default time zone using appropriate backend static QTimeZonePrivate *newBackendTimeZone() { -#ifdef QT_NO_SYSTEMLOCALE -#if QT_CONFIG(icu) - return new QIcuTimeZonePrivate(); -#else - return new QUtcTimeZonePrivate(); -#endif -#else #if defined(Q_OS_DARWIN) return new QMacTimeZonePrivate(); #elif defined(Q_OS_ANDROID) @@ -41,21 +34,13 @@ static QTimeZonePrivate *newBackendTimeZone() return new QWinTimeZonePrivate(); #else return new QUtcTimeZonePrivate(); -#endif // System Locales -#endif // QT_NO_SYSTEMLOCALE +#endif // Backend selection } // Create named time zone using appropriate backend static QTimeZonePrivate *newBackendTimeZone(const QByteArray &ianaId) { Q_ASSERT(!ianaId.isEmpty()); -#ifdef QT_NO_SYSTEMLOCALE -#if QT_CONFIG(icu) - return new QIcuTimeZonePrivate(ianaId); -#else - return new QUtcTimeZonePrivate(ianaId); -#endif -#else #if defined(Q_OS_DARWIN) return new QMacTimeZonePrivate(ianaId); #elif defined(Q_OS_ANDROID) @@ -68,8 +53,7 @@ static QTimeZonePrivate *newBackendTimeZone(const QByteArray &ianaId) return new QWinTimeZonePrivate(ianaId); #else return new QUtcTimeZonePrivate(ianaId); -#endif // System Locales -#endif // QT_NO_SYSTEMLOCALE +#endif // Backend selection } class QTimeZoneSingleton @@ -77,10 +61,11 @@ class QTimeZoneSingleton public: QTimeZoneSingleton() : backend(newBackendTimeZone()) {} - // The global_tz is the tz to use in static methods such as availableTimeZoneIds() and - // isTimeZoneIdAvailable() and to create named IANA time zones. This is usually the host - // system, but may be different if the host resources are insufficient or if - // QT_NO_SYSTEMLOCALE is set. A simple UTC backend is used if no alternative is available. + // The global_tz is the tz to use in static methods such as + // availableTimeZoneIds() and isTimeZoneIdAvailable() and to create named + // IANA time zones. This is usually the host system, but may be different if + // the host resources are insufficient. A simple UTC backend is used if no + // alternative is available. QExplicitlySharedDataPointer backend; }; diff --git a/src/corelib/time/qtimezone.h b/src/corelib/time/qtimezone.h index e9599ae6151..9a0e2631eb3 100644 --- a/src/corelib/time/qtimezone.h +++ b/src/corelib/time/qtimezone.h @@ -13,7 +13,7 @@ #include -#if QT_CONFIG(timezone) && (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE) +#if QT_CONFIG(timezone) && (defined(Q_OS_DARWIN) || defined(Q_QDOC)) Q_FORWARD_DECLARE_CF_TYPE(CFTimeZone); Q_FORWARD_DECLARE_OBJC_CLASS(NSTimeZone); #endif @@ -214,7 +214,7 @@ public: static QList windowsIdToIanaIds(const QByteArray &windowsId, QLocale::Territory territory); -# if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE) +# if defined(Q_OS_DARWIN) || defined(Q_QDOC) static QTimeZone fromCFTimeZone(CFTimeZoneRef timeZone); CFTimeZoneRef toCFTimeZone() const Q_DECL_CF_RETURNS_RETAINED; static QTimeZone fromNSTimeZone(const NSTimeZone *timeZone); diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp index 71b1674b846..79f836a5b8b 100644 --- a/src/corelib/time/qtimezoneprivate.cpp +++ b/src/corelib/time/qtimezoneprivate.cpp @@ -756,8 +756,11 @@ static bool isEntryInIanaList(QByteArrayView id, QByteArrayView ianaIds) } /* - UTC Offset implementation, used when QT_NO_SYSTEMLOCALE set and ICU is not being used, - or for QDateTimes with a Qt:Spec of Qt::OffsetFromUtc. + UTC Offset backend. + + Always present, based on UTC-offset zones. + Complements platform-specific backends. + Equivalent to Qt::OffsetFromUtc lightweight time representations. */ // Create default UTC time zone