Isolate an "enough like C locale" test and use consistently
Various checks for whether a locale was suitable for use of ASCII offset formats were expressed in terms of QLocale::C. One was wrongly expressed in terms of isDataLocale(), which is meant to be true for the locale the backend thinks its data is suitable for. Write a new method of QTimeZonePrivate to check for this, accepting en-Latn-* as a good enough match, and deploy where it's the right test. Pick-to: 6.8 Change-Id: Ieab129eb5c252732b8916fce017ec0a22684eba8 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 023a8d48e28f27da9fab097ecbe9acfbb8323544) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
585cdfbd17
commit
7549a5c388
@ -172,7 +172,7 @@ QString QTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
|
||||
{
|
||||
const Data tran = data(atMSecsSinceEpoch);
|
||||
if (tran.atMSecsSinceEpoch != invalidMSecs()) {
|
||||
if (nameType == QTimeZone::OffsetName && locale.language() == QLocale::C)
|
||||
if (nameType == QTimeZone::OffsetName && isAnglicLocale(locale))
|
||||
return isoOffsetFormat(tran.offsetFromUtc);
|
||||
if (nameType == QTimeZone::ShortName && isDataLocale(locale))
|
||||
return tran.abbreviation;
|
||||
@ -194,7 +194,7 @@ QString QTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
|
||||
{
|
||||
const Data tran = data(timeType);
|
||||
if (tran.atMSecsSinceEpoch != invalidMSecs()) {
|
||||
if (nameType == QTimeZone::OffsetName && isDataLocale(locale))
|
||||
if (nameType == QTimeZone::OffsetName && isAnglicLocale(locale))
|
||||
return isoOffsetFormat(tran.offsetFromUtc);
|
||||
|
||||
#if QT_CONFIG(timezone_locale)
|
||||
@ -1041,8 +1041,8 @@ QTimeZonePrivate::Data QUtcTimeZonePrivate::data(QTimeZone::TimeType timeType) c
|
||||
|
||||
bool QUtcTimeZonePrivate::isDataLocale(const QLocale &locale) const
|
||||
{
|
||||
// Officially only supports C locale names; these are surely also viable for English.
|
||||
return locale.language() == QLocale::C || locale.language() == QLocale::English;
|
||||
// Officially only supports C locale names; these are surely also viable for en-Latn-*.
|
||||
return isAnglicLocale(locale);
|
||||
}
|
||||
|
||||
void QUtcTimeZonePrivate::init(const QByteArray &zoneId, int offsetSeconds, const QString &name,
|
||||
|
@ -109,6 +109,13 @@ public:
|
||||
virtual Data data(qint64 forMSecsSinceEpoch) const;
|
||||
virtual Data data(QTimeZone::TimeType timeType) const;
|
||||
virtual bool isDataLocale(const QLocale &locale) const;
|
||||
static bool isAnglicLocale(const QLocale &locale)
|
||||
{
|
||||
// Sufficiently like the C locale for displayName()-related purposes:
|
||||
const QLocale::Language lang = locale.language();
|
||||
return lang == QLocale::C
|
||||
|| (lang == QLocale::English && locale.script() == QLocale::LatinScript);
|
||||
}
|
||||
QDateTimePrivate::ZoneState stateAtZoneTime(qint64 forLocalMSecs,
|
||||
QDateTimePrivate::TransitionOptions resolve) const;
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
|
||||
if (nameType == QTimeZone::ShortName)
|
||||
return tran.abbreviation;
|
||||
// Save base class repeating the data(timeType) query:
|
||||
if (locale.language() == QLocale::C)
|
||||
if (isAnglicLocale(locale))
|
||||
return isoOffsetFormat(tran.offsetFromUtc);
|
||||
}
|
||||
}
|
||||
@ -1176,8 +1176,8 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::data(QTimeZone::TimeType timeType) co
|
||||
|
||||
bool QTzTimeZonePrivate::isDataLocale(const QLocale &locale) const
|
||||
{
|
||||
// TZ data uses English / C locale names:
|
||||
return locale.language() == QLocale::C || locale.language() == QLocale::English;
|
||||
// TZ data uses en-Latn-* / C locale names:
|
||||
return isAnglicLocale(locale);
|
||||
}
|
||||
|
||||
bool QTzTimeZonePrivate::hasTransitions() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user