summaryrefslogtreecommitdiffstats
path: root/src/corelib/time
diff options
context:
space:
mode:
authorJiDe Zhang <zhangjide@uniontech.com>2021-03-09 16:19:54 +0800
committerJiDe Zhang <zhangjide@uniontech.com>2021-04-15 20:17:49 +0800
commit50a7eb8cf75a2f9cebde6d0d23c108e5e7f1870b (patch)
treec947e4746bb55f723c4005534cb98501f083036a /src/corelib/time
parent7c8d45cb2635ab44d85d85288fd74ef72909264c (diff)
Add the "Territory" enumerated type for QLocale
The use of "Country" is misleading as some entries in the enumeration are not countries (eg, HongKong), for all that most are. The Unicode Consortium's Common Locale Data Repository (CLDR, from which QLocale's data is taken) calls these territories, so introduce territory-based names and prepare to deprecate the country-based ones in due course. [ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for its Country enumeration, and associated territory-based names to match its country-named methods, to better match the usage in relevant standards. The country-based names shall in due course be deprecated in favor of the territory-based names. Fixes: QTBUG-91686 Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/time')
-rw-r--r--src/corelib/time/qcalendarbackend_p.h2
-rw-r--r--src/corelib/time/qhijricalendar_data_p.h4
-rw-r--r--src/corelib/time/qjalalicalendar_data_p.h4
-rw-r--r--src/corelib/time/qromancalendar_data_p.h4
-rw-r--r--src/corelib/time/qtimezone.cpp78
-rw-r--r--src/corelib/time/qtimezone.h12
-rw-r--r--src/corelib/time/qtimezoneprivate.cpp46
-rw-r--r--src/corelib/time/qtimezoneprivate_android.cpp6
-rw-r--r--src/corelib/time/qtimezoneprivate_data_p.h2
-rw-r--r--src/corelib/time/qtimezoneprivate_icu.cpp4
-rw-r--r--src/corelib/time/qtimezoneprivate_p.h24
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp14
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp16
13 files changed, 116 insertions, 100 deletions
diff --git a/src/corelib/time/qcalendarbackend_p.h b/src/corelib/time/qcalendarbackend_p.h
index 8a3d4815bc..b011fa0f62 100644
--- a/src/corelib/time/qcalendarbackend_p.h
+++ b/src/corelib/time/qcalendarbackend_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
// Locale-related parts, mostly handled in ../text/qlocale.cpp
struct QCalendarLocale {
- quint16 m_language_id, m_script_id, m_country_id;
+ quint16 m_language_id, m_script_id, m_territory_id;
#define rangeGetter(name) \
QLocaleData::DataRange name() const { return { m_ ## name ## _idx, m_ ## name ## _size }; }
diff --git a/src/corelib/time/qhijricalendar_data_p.h b/src/corelib/time/qhijricalendar_data_p.h
index 48932eb1b6..012f09ef13 100644
--- a/src/corelib/time/qhijricalendar_data_p.h
+++ b/src/corelib/time/qhijricalendar_data_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2020-10-30 from the
+ This part of the file was generated on 2021-03-12 from the
Common Locale Data Repository v38
http://www.unicode.org/cldr/
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
static const QCalendarLocale locale_data[] = {
// lang script terr sLong long sShrt short sNarw narow Sizes...
- { 1, 0, 0, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// C/AnyScript/AnyCountry
+ { 1, 0, 0, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// C/AnyScript/AnyTerritory
{ 3, 66, 77, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// Afar/Latin/Ethiopia
{ 4, 66, 216, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// Afrikaans/Latin/South Africa
{ 4, 66, 162, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// Afrikaans/Latin/Namibia
diff --git a/src/corelib/time/qjalalicalendar_data_p.h b/src/corelib/time/qjalalicalendar_data_p.h
index 8106550670..1c82e75e84 100644
--- a/src/corelib/time/qjalalicalendar_data_p.h
+++ b/src/corelib/time/qjalalicalendar_data_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2020-10-30 from the
+ This part of the file was generated on 2021-03-12 from the
Common Locale Data Repository v38
http://www.unicode.org/cldr/
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
static const QCalendarLocale locale_data[] = {
// lang script terr sLong long sShrt short sNarw narow Sizes...
- { 1, 0, 0, 0, 0, 83, 83, 130, 153, 83, 83, 47, 47, 23, 26 },// C/AnyScript/AnyCountry
+ { 1, 0, 0, 0, 0, 83, 83, 130, 153, 83, 83, 47, 47, 23, 26 },// C/AnyScript/AnyTerritory
{ 3, 66, 77, 0, 0, 0, 0, 153, 153, 83, 83, 83, 83, 26, 26 },// Afar/Latin/Ethiopia
{ 4, 66, 216, 0, 0, 0, 0, 153, 153, 83, 83, 83, 83, 26, 26 },// Afrikaans/Latin/South Africa
{ 4, 66, 162, 0, 0, 0, 0, 153, 153, 83, 83, 83, 83, 26, 26 },// Afrikaans/Latin/Namibia
diff --git a/src/corelib/time/qromancalendar_data_p.h b/src/corelib/time/qromancalendar_data_p.h
index 6f19f573fb..46926c45de 100644
--- a/src/corelib/time/qromancalendar_data_p.h
+++ b/src/corelib/time/qromancalendar_data_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2020-10-30 from the
+ This part of the file was generated on 2021-03-12 from the
Common Locale Data Repository v38
http://www.unicode.org/cldr/
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
static const QCalendarLocale locale_data[] = {
// lang script terr sLong long sShrt short sNarw narow Sizes...
- { 1, 0, 0, 0, 0, 85, 85, 132, 155, 85, 85, 47, 47, 23, 26 },// C/AnyScript/AnyCountry
+ { 1, 0, 0, 0, 0, 85, 85, 132, 155, 85, 85, 47, 47, 23, 26 },// C/AnyScript/AnyTerritory
{ 3, 66, 77, 181, 181, 181, 181, 155, 155, 47, 47, 47, 47, 26, 26 },// Afar/Latin/Ethiopia
{ 4, 66, 216, 228, 228, 319, 319, 132, 132, 91, 91, 58, 58, 23, 23 },// Afrikaans/Latin/South Africa
{ 4, 66, 162, 228, 228, 319, 319, 132, 132, 91, 91, 58, 58, 23, 23 },// Afrikaans/Latin/Namibia
diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp
index 5f4589eda0..b9c6d727c8 100644
--- a/src/corelib/time/qtimezone.cpp
+++ b/src/corelib/time/qtimezone.cpp
@@ -373,23 +373,23 @@ QTimeZone::QTimeZone(int offsetSeconds)
Creates a custom time zone with an ID of \a ianaId and an offset from UTC
of \a offsetSeconds. The \a name will be the name used by displayName()
for the LongName, the \a abbreviation will be used by displayName() for the
- ShortName and by abbreviation(), and the optional \a country will be used
- by country(). The \a comment is an optional note that may be displayed in
+ ShortName and by abbreviation(), and the optional \a territory will be used
+ by territory(). The \a comment is an optional note that may be displayed in
a GUI to assist users in selecting a time zone.
The \a ianaId must not be one of the available system IDs returned by
availableTimeZoneIds(). The \a offsetSeconds from UTC must be in the range
-14 hours to +14 hours.
- If the custom time zone does not have a specific country then set it to the
- default value of QLocale::AnyCountry.
+ If the custom time zone does not have a specific territory then set it to the
+ default value of QLocale::AnyTerritory.
*/
QTimeZone::QTimeZone(const QByteArray &ianaId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country, const QString &comment)
+ const QString &abbreviation, QLocale::Territory territory, const QString &comment)
{
if (!isTimeZoneIdAvailable(ianaId))
- d = new QUtcTimeZonePrivate(ianaId, offsetSeconds, name, abbreviation, country, comment);
+ d = new QUtcTimeZonePrivate(ianaId, offsetSeconds, name, abbreviation, territory, comment);
}
/*!
@@ -482,7 +482,7 @@ bool QTimeZone::isValid() const
Returns the IANA ID for the time zone.
IANA IDs are used on all platforms. On Windows these are translated
- from the Windows ID into the closest IANA ID for the time zone and country.
+ from the Windows ID into the closest IANA ID for the time zone and territory.
*/
QByteArray QTimeZone::id() const
@@ -491,13 +491,27 @@ QByteArray QTimeZone::id() const
}
/*!
- Returns the country for the time zone.
+ \since 6.2
+
+ Returns the territory for the time zone.
+*/
+QLocale::Territory QTimeZone::territory() const
+{
+ return isValid() ? d->territory() : QLocale::AnyTerritory;
+}
+
+#if QT_DEPRECATED_SINCE(6, 6)
+/*!
+ \obsolete Use territory() instead.
+
+ Returns the territory for the time zone.
*/
QLocale::Country QTimeZone::country() const
{
- return isValid() ? d->country() : QLocale::AnyCountry;
+ return territory();
}
+#endif
/*!
Returns any comment for the time zone.
@@ -841,20 +855,20 @@ QList<QByteArray> QTimeZone::availableTimeZoneIds()
}
/*!
- Returns a list of all available IANA time zone IDs for a given \a country.
+ Returns a list of all available IANA time zone IDs for a given \a territory.
- As a special case, a \a country of Qt::AnyCountry returns those time zones
- that do not have any country related to them, such as UTC. If you require
+ As a special case, a \a territory of Qt::AnyTerritory returns those time zones
+ that do not have any territory related to them, such as UTC. If you require
a list of all time zone IDs for all countries then use the standard
availableTimeZoneIds() method.
\sa isTimeZoneIdAvailable()
*/
-QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Country country)
+QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Territory territory)
{
- return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(country),
- global_tz->backend->availableTimeZoneIds(country));
+ return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(territory),
+ global_tz->backend->availableTimeZoneIds(territory));
}
/*!
@@ -898,21 +912,20 @@ QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId)
}
/*!
- Returns the default IANA ID for a given \a windowsId and \a country.
+ Returns the default IANA ID for a given \a windowsId and \a territory.
- Because a Windows ID can cover several IANA IDs within a given country,
- the most frequently used IANA ID in that country is returned.
+ Because a Windows ID can cover several IANA IDs within a given territory,
+ the most frequently used IANA ID in that territory is returned.
- As a special case, QLocale::AnyCountry returns the default of those IANA IDs
- that do not have any specific country.
+ As a special case, QLocale::AnyTerritory returns the default of those IANA IDs
+ that do not have any specific territory.
\sa ianaIdToWindowsId(), windowsIdToIanaIds()
*/
-QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country)
+QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId, QLocale::Territory territory)
{
- return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId, country);
+ return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId, territory);
}
/*!
@@ -929,21 +942,20 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId)
}
/*!
- Returns all the IANA IDs for a given \a windowsId and \a country.
+ Returns all the IANA IDs for a given \a windowsId and \a territory.
- As a special case QLocale::AnyCountry returns those IANA IDs that do
- not have any specific country.
+ As a special case QLocale::AnyTerritory returns those IANA IDs that do
+ not have any specific territory.
The returned list is in order of frequency of usage, i.e. larger zones
- within a country are listed first.
+ within a territory are listed first.
\sa ianaIdToWindowsId(), windowsIdToDefaultIanaId()
*/
-QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country)
+QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId, QLocale::Territory territory)
{
- return QTimeZonePrivate::windowsIdToIanaIds(windowsId, country);
+ return QTimeZonePrivate::windowsIdToIanaIds(windowsId, territory);
}
#ifndef QT_NO_DATASTREAM
@@ -969,16 +981,16 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
int utcOffset;
QString name;
QString abbreviation;
- int country;
+ int territory;
QString comment;
- ds >> ianaId >> utcOffset >> name >> abbreviation >> country >> comment;
+ ds >> ianaId >> utcOffset >> name >> abbreviation >> territory >> comment;
// Try creating as a system timezone, which succeeds (producing a valid
// zone) iff ianaId is valid; we can then ignore the other data.
tz = QTimeZone(ianaId.toUtf8());
// If not, then construct a custom timezone using all the saved values:
if (!tz.isValid())
tz = QTimeZone(ianaId.toUtf8(), utcOffset, name, abbreviation,
- QLocale::Country(country), comment);
+ QLocale::Territory(territory), comment);
} else {
tz = QTimeZone(ianaId.toUtf8());
}
diff --git a/src/corelib/time/qtimezone.h b/src/corelib/time/qtimezone.h
index 5fd9044ef5..6039749689 100644
--- a/src/corelib/time/qtimezone.h
+++ b/src/corelib/time/qtimezone.h
@@ -93,7 +93,7 @@ public:
explicit QTimeZone(const QByteArray &ianaId);
explicit QTimeZone(int offsetSeconds);
QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country = QLocale::AnyCountry,
+ const QString &abbreviation, QLocale::Territory territory = QLocale::AnyTerritory,
const QString &comment = QString());
QTimeZone(const QTimeZone &other);
~QTimeZone();
@@ -110,7 +110,11 @@ public:
bool isValid() const;
QByteArray id() const;
+ QLocale::Territory territory() const;
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Use territory() instead")
QLocale::Country country() const;
+#endif
QString comment() const;
QString displayName(const QDateTime &atDateTime,
@@ -142,16 +146,16 @@ public:
static bool isTimeZoneIdAvailable(const QByteArray &ianaId);
static QList<QByteArray> availableTimeZoneIds();
- static QList<QByteArray> availableTimeZoneIds(QLocale::Country country);
+ static QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory);
static QList<QByteArray> availableTimeZoneIds(int offsetSeconds);
static QByteArray ianaIdToWindowsId(const QByteArray &ianaId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE)
static QTimeZone fromCFTimeZone(CFTimeZoneRef timeZone);
diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp
index 5588cf8cce..be00f658bc 100644
--- a/src/corelib/time/qtimezoneprivate.cpp
+++ b/src/corelib/time/qtimezoneprivate.cpp
@@ -171,7 +171,7 @@ QByteArray QTimeZonePrivate::id() const
return m_id;
}
-QLocale::Country QTimeZonePrivate::country() const
+QLocale::Territory QTimeZonePrivate::territory() const
{
// Default fall-back mode, use the zoneTable to find Region of known Zones
for (int i = 0; i < zoneDataTableSize; ++i) {
@@ -181,11 +181,11 @@ QLocale::Country QTimeZonePrivate::country() const
qsizetype index = idView.indexOf(' ');
QByteArrayView next = index == -1 ? idView : idView.first(index);
if (next == m_id)
- return (QLocale::Country)data->country;
+ return (QLocale::Territory)data->territory;
idView = index == -1 ? QByteArrayView() : idView.sliced(index + 1);
}
}
- return QLocale::AnyCountry;
+ return QLocale::AnyTerritory;
}
QString QTimeZonePrivate::comment() const
@@ -524,14 +524,14 @@ QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds() const
return QList<QByteArray>();
}
-QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
{
// Default fall-back mode, use the zoneTable to find Region of know Zones
QList<QByteArray> regions;
// First get all Zones in the Zones table belonging to the Region
for (int i = 0; i < zoneDataTableSize; ++i) {
- if (zoneData(i)->country == country)
+ if (zoneData(i)->territory == territory)
regions += ianaId(zoneData(i)).split(' ');
}
@@ -739,9 +739,9 @@ QByteArray QTimeZonePrivate::windowsIdToDefaultIanaId(const QByteArray &windowsI
}
QByteArray QTimeZonePrivate::windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country)
+ QLocale::Territory territory)
{
- const QList<QByteArray> list = windowsIdToIanaIds(windowsId, country);
+ const QList<QByteArray> list = windowsIdToIanaIds(windowsId, territory);
if (list.count() > 0)
return list.first();
else
@@ -765,13 +765,13 @@ QList<QByteArray> QTimeZonePrivate::windowsIdToIanaIds(const QByteArray &windows
}
QList<QByteArray> QTimeZonePrivate::windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country)
+ QLocale::Territory territory)
{
const quint16 windowsIdKey = toWindowsIdKey(windowsId);
for (int i = 0; i < zoneDataTableSize; ++i) {
const QZoneData *data = zoneData(i);
// Return the region matches in preference order
- if (data->windowsIdKey == windowsIdKey && data->country == (quint16) country)
+ if (data->windowsIdKey == windowsIdKey && data->territory == static_cast<quint16>(territory))
return ianaId(data).split(' ');
}
@@ -793,7 +793,7 @@ template<> QTimeZonePrivate *QSharedDataPointer<QTimeZonePrivate>::clone()
QUtcTimeZonePrivate::QUtcTimeZonePrivate()
{
const QString name = utcQString();
- init(utcQByteArray(), 0, name, name, QLocale::AnyCountry, name);
+ init(utcQByteArray(), 0, name, name, QLocale::AnyTerritory, name);
}
// Create a named UTC time zone
@@ -805,7 +805,7 @@ QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &id)
const QByteArray uid = utcId(data);
if (uid == id) {
QString name = QString::fromUtf8(id);
- init(id, data->offsetFromUtc, name, name, QLocale::AnyCountry, name);
+ init(id, data->offsetFromUtc, name, name, QLocale::AnyTerritory, name);
break;
}
}
@@ -848,21 +848,21 @@ qint64 QUtcTimeZonePrivate::offsetFromUtcString(const QByteArray &id)
QUtcTimeZonePrivate::QUtcTimeZonePrivate(qint32 offsetSeconds)
{
QString utcId = isoOffsetFormat(offsetSeconds, QTimeZone::ShortName);
- init(utcId.toUtf8(), offsetSeconds, utcId, utcId, QLocale::AnyCountry, utcId);
+ init(utcId.toUtf8(), offsetSeconds, utcId, utcId, QLocale::AnyTerritory, utcId);
}
QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &zoneId, int offsetSeconds,
const QString &name, const QString &abbreviation,
- QLocale::Country country, const QString &comment)
+ QLocale::Territory territory, const QString &comment)
{
- init(zoneId, offsetSeconds, name, abbreviation, country, comment);
+ init(zoneId, offsetSeconds, name, abbreviation, territory, comment);
}
QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QUtcTimeZonePrivate &other)
: QTimeZonePrivate(other), m_name(other.m_name),
m_abbreviation(other.m_abbreviation),
m_comment(other.m_comment),
- m_country(other.m_country),
+ m_territory(other.m_territory),
m_offsetFromUtc(other.m_offsetFromUtc)
{
}
@@ -892,20 +892,20 @@ void QUtcTimeZonePrivate::init(const QByteArray &zoneId)
}
void QUtcTimeZonePrivate::init(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country,
+ const QString &abbreviation, QLocale::Territory territory,
const QString &comment)
{
m_id = zoneId;
m_offsetFromUtc = offsetSeconds;
m_name = name;
m_abbreviation = abbreviation;
- m_country = country;
+ m_territory = territory;
m_comment = comment;
}
-QLocale::Country QUtcTimeZonePrivate::country() const
+QLocale::Territory QUtcTimeZonePrivate::territory() const
{
- return m_country;
+ return m_territory;
}
QString QUtcTimeZonePrivate::comment() const
@@ -974,10 +974,10 @@ QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(QLocale::Territory country) const
{
- // If AnyCountry then is request for all non-region offset codes
- if (country == QLocale::AnyCountry)
+ // If AnyTerritory then is request for all non-region offset codes
+ if (country == QLocale::AnyTerritory)
return availableTimeZoneIds();
return QList<QByteArray>();
}
@@ -1002,7 +1002,7 @@ QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(qint32 offsetSeconds
void QUtcTimeZonePrivate::serialize(QDataStream &ds) const
{
ds << QStringLiteral("OffsetFromUtc") << QString::fromUtf8(m_id) << m_offsetFromUtc << m_name
- << m_abbreviation << (qint32) m_country << m_comment;
+ << m_abbreviation << static_cast<qint32>(m_territory) << m_comment;
}
#endif // QT_NO_DATASTREAM
diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp
index d10433ff23..9be5ea4a73 100644
--- a/src/corelib/time/qtimezoneprivate_android.cpp
+++ b/src/corelib/time/qtimezoneprivate_android.cpp
@@ -90,14 +90,14 @@ static QJniObject getDisplayName(QJniObject zone, jint style, jboolean dst,
{
QJniObject jlanguage
= QJniObject::fromString(QLocale::languageToString(locale.language()));
- QJniObject jcountry
- = QJniObject::fromString(QLocale::countryToString(locale.country()));
+ QJniObject jterritory
+ = QJniObject::fromString(QLocale::territoryToString(locale.territory()));
QJniObject
jvariant = QJniObject::fromString(QLocale::scriptToString(locale.script()));
QJniObject jlocale("java.util.Locale",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
static_cast<jstring>(jlanguage.object()),
- static_cast<jstring>(jcountry.object()),
+ static_cast<jstring>(jterritory.object()),
static_cast<jstring>(jvariant.object()));
return zone.callObjectMethod("getDisplayName",
diff --git a/src/corelib/time/qtimezoneprivate_data_p.h b/src/corelib/time/qtimezoneprivate_data_p.h
index 16af5625f1..9438984f34 100644
--- a/src/corelib/time/qtimezoneprivate_data_p.h
+++ b/src/corelib/time/qtimezoneprivate_data_p.h
@@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE
struct QZoneData {
quint16 windowsIdKey; // Windows ID Key
- quint16 country; // Country of IANA ID's, AnyCountry means No Country
+ quint16 territory; // Territory of IANA ID's, AnyTerritory means No Territory
quint16 ianaIdIndex; // All IANA ID's for the Windows ID and Country, space separated
};
diff --git a/src/corelib/time/qtimezoneprivate_icu.cpp b/src/corelib/time/qtimezoneprivate_icu.cpp
index 198e1530e4..706deb2b17 100644
--- a/src/corelib/time/qtimezoneprivate_icu.cpp
+++ b/src/corelib/time/qtimezoneprivate_icu.cpp
@@ -475,9 +475,9 @@ QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
{
- const QLatin1String regionCode = QLocalePrivate::countryToCode(country);
+ const QLatin1String regionCode = QLocalePrivate::territoryToCode(territory);
const QByteArray regionCodeUtf8 = QString(regionCode).toUtf8();
UErrorCode status = U_ZERO_ERROR;
UEnumeration *uenum = ucal_openCountryTimeZones(regionCodeUtf8.data(), &status);
diff --git a/src/corelib/time/qtimezoneprivate_p.h b/src/corelib/time/qtimezoneprivate_p.h
index 164a1b790f..feb6ab5369 100644
--- a/src/corelib/time/qtimezoneprivate_p.h
+++ b/src/corelib/time/qtimezoneprivate_p.h
@@ -101,7 +101,7 @@ public:
bool isValid() const;
QByteArray id() const;
- virtual QLocale::Country country() const;
+ virtual QLocale::Territory territory() const;
virtual QString comment() const;
virtual QString displayName(qint64 atMSecsSinceEpoch,
@@ -131,7 +131,7 @@ public:
virtual bool isTimeZoneIdAvailable(const QByteArray &ianaId) const;
virtual QList<QByteArray> availableTimeZoneIds() const;
- virtual QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const;
+ virtual QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const;
virtual QList<QByteArray> availableTimeZoneIds(int utcOffset) const;
virtual void serialize(QDataStream &ds) const;
@@ -151,10 +151,10 @@ public:
static QByteArray ianaIdToWindowsId(const QByteArray &ianaId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
// returns "UTC" QString and QByteArray
[[nodiscard]] static inline QString utcQString()
@@ -185,7 +185,7 @@ public:
QUtcTimeZonePrivate(qint32 offsetSeconds);
// Create custom offset from UTC
QUtcTimeZonePrivate(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country,
+ const QString &abbreviation, QLocale::Territory territory,
const QString &comment);
QUtcTimeZonePrivate(const QUtcTimeZonePrivate &other);
virtual ~QUtcTimeZonePrivate();
@@ -197,7 +197,7 @@ public:
Data data(qint64 forMSecsSinceEpoch) const override;
- QLocale::Country country() const override;
+ QLocale::Territory territory() const override;
QString comment() const override;
QString displayName(QTimeZone::TimeType timeType,
@@ -212,7 +212,7 @@ public:
bool isTimeZoneIdAvailable(const QByteArray &ianaId) const override;
QList<QByteArray> availableTimeZoneIds() const override;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Territory country) const override;
QList<QByteArray> availableTimeZoneIds(int utcOffset) const override;
void serialize(QDataStream &ds) const override;
@@ -220,13 +220,13 @@ public:
private:
void init(const QByteArray &zoneId);
void init(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country,
+ const QString &abbreviation, QLocale::Territory territory,
const QString &comment);
QString m_name;
QString m_abbreviation;
QString m_comment;
- QLocale::Country m_country;
+ QLocale::Territory m_territory;
int m_offsetFromUtc;
};
@@ -263,7 +263,7 @@ public:
QByteArray systemTimeZoneId() const override;
QList<QByteArray> availableTimeZoneIds() const override;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const override;
QList<QByteArray> availableTimeZoneIds(int offsetFromUtc) const override;
private:
@@ -315,7 +315,7 @@ public:
QTzTimeZonePrivate *clone() const override;
- QLocale::Country country() const override;
+ QLocale::Territory territory() const override;
QString comment() const override;
QString displayName(qint64 atMSecsSinceEpoch,
@@ -343,7 +343,7 @@ public:
bool isTimeZoneIdAvailable(const QByteArray &ianaId) const override;
QList<QByteArray> availableTimeZoneIds() const override;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const override;
private:
void init(const QByteArray &ianaId);
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
index 72ac0fe8de..9daffbad5d 100644
--- a/src/corelib/time/qtimezoneprivate_tz.cpp
+++ b/src/corelib/time/qtimezoneprivate_tz.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
*/
struct QTzTimeZone {
- QLocale::Country country;
+ QLocale::Territory territory;
QByteArray comment;
};
@@ -98,7 +98,7 @@ static QTzTimeZoneHash loadTzTimeZones()
if (Q_LIKELY(cut > 0)) {
QTzTimeZone zone;
// TODO: QLocale & friends could do this look-up without UTF8-conversion:
- zone.country = QLocalePrivate::codeToCountry(QString::fromUtf8(text.first(cut)));
+ zone.territory = QLocalePrivate::codeToTerritory(QString::fromUtf8(text.first(cut)));
text = text.sliced(cut + 1);
cut = text.indexOf('\t');
if (Q_LIKELY(cut >= 0)) { // Skip over Coordinates, read ID and comment
@@ -916,9 +916,9 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
}
}
-QLocale::Country QTzTimeZonePrivate::country() const
+QLocale::Territory QTzTimeZonePrivate::territory() const
{
- return tzZones->value(m_id).country;
+ return tzZones->value(m_id).territory;
}
QString QTzTimeZonePrivate::comment() const
@@ -1165,12 +1165,12 @@ QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
{
- // TODO AnyCountry
+ // TODO AnyTerritory
QList<QByteArray> result;
for (auto it = tzZones->cbegin(), end = tzZones->cend(); it != end; ++it) {
- if (it.value().country == country)
+ if (it.value().territory == territory)
result << it.key();
}
std::sort(result.begin(), result.end());
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp
index 7c80dbc38b..0846890b60 100644
--- a/src/corelib/time/qtimezoneprivate_win.cpp
+++ b/src/corelib/time/qtimezoneprivate_win.cpp
@@ -376,13 +376,13 @@ int yearEndOffset(const QWinTimeZonePrivate::QWinTransitionRule &rule, int year)
return offset;
}
-QLocale::Country userCountry()
+QLocale::Territory userTerritory()
{
const GEOID id = GetUserGeoID(GEOCLASS_NATION);
wchar_t code[3];
const int size = GetGeoInfo(id, GEO_ISO2, code, 3, 0);
- return (size == 3) ? QLocalePrivate::codeToCountry(QStringView(code, size))
- : QLocale::AnyCountry;
+ return (size == 3) ? QLocalePrivate::codeToTerritory(QStringView(code, size))
+ : QLocale::AnyTerritory;
}
// Index of last rule in rules with .startYear <= year:
@@ -727,13 +727,13 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSec
QByteArray QWinTimeZonePrivate::systemTimeZoneId() const
{
- const QLocale::Country country = userCountry();
+ const QLocale::Territory territory = userTerritory();
const QByteArray windowsId = windowsSystemZoneId();
QByteArray ianaId;
- // If we have a real country, then try get a specific match for that country
- if (country != QLocale::AnyCountry)
- ianaId = windowsIdToDefaultIanaId(windowsId, country);
- // If we don't have a real country, or there wasn't a specific match, try the global default
+ // If we have a real territory, then try get a specific match for that territory
+ if (territory != QLocale::AnyTerritory)
+ ianaId = windowsIdToDefaultIanaId(windowsId, territory);
+ // If we don't have a real territory, or there wasn't a specific match, try the global default
if (ianaId.isEmpty())
ianaId = windowsIdToDefaultIanaId(windowsId);
return ianaId;