Cope with IANA DB links that aren't in the CLDR alias mapping

As documented in the LMDL spec (see comment on unAliasedLinks in the
diff) not all links in the IANA DB are represented as CLDR
aliases. This didn't surface until a recent update to the IANA DB used
symlinks more aggressively.

Add a set of known cases of this to exclude from hasAlternativeName()
checks and let's hope it doesn't grow too often.

Pick to 6.8 required #include <set> that was transitively available on
dev but not on 6.8

Change-Id: Ia12d9fcad96485469ded6bdb7345a400bd34efae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ae6b6bf363d71184269104e4bfbb19a9abd27a24)
This commit is contained in:
Edward Welbourne 2024-12-05 14:31:21 +01:00
parent dff71f52e5
commit 2fa5a525a3

View File

@ -13,6 +13,8 @@
#include <QOperatingSystemVersion>
#endif
#include <set>
#if defined(Q_OS_WIN) && !QT_CONFIG(icu)
# define USING_WIN_TZ
#endif
@ -70,11 +72,32 @@ private Q_SLOTS:
private:
void printTimeZone(const QTimeZone &tz);
#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(timezone)
#if QT_CONFIG(timezone)
# if defined(QT_BUILD_INTERNAL)
// Generic tests of privates, called by implementation-specific private tests:
void testCetPrivate(const QTimeZonePrivate &tzp);
void testEpochTranPrivate(const QTimeZonePrivate &tzp);
#endif // QT_BUILD_INTERNAL && timezone backends
# endif // QT_BUILD_INTERNAL
// Where tzdb contains a link between zones in different territories, CLDR
// doesn't treat those as aliases for one another. For details see "Links in
// the tz database" at:
// https://www.unicode.org/reports/tr35/#time-zone-identifiers
// Some of these could be identified as equivalent by looking at metazone
// histories but, for now, we stick with CLDR's notion of alias.
const std::set<QByteArrayView> unAliasedLinks = {
// By continent:
"America/Kralendijk", "America/Lower_Princes", "America/Marigot", "America/St_Barthelemy",
"Antarctica/South_Pole",
"Arctic/Longyearbyen",
"Asia/Choibalsan",
"Atlantic/Jan_Mayen",
"Europe/Bratislava", "Europe/Busingen", "Europe/Mariehamn",
"Europe/Podgorica", "Europe/San_Marino", "Europe/Vatican",
// Assorted legacy abbreviations and POSIX zones:
"CET", "EET", "EST", "HST", "MET", "MST", "WET",
"CST6CDT", "EST5EDT", "MST7MDT", "PST8PDT",
};
#endif // timezone backends
// Set to true to print debug output, test Display Names and run long stress tests
static constexpr bool debug = false;
};
@ -565,7 +588,8 @@ void tst_QTimeZone::isTimeZoneIdAvailable()
QVERIFY2(QTimeZone::isTimeZoneIdAvailable(id), id);
const QTimeZone zone(id);
QVERIFY2(zone.isValid(), id);
QVERIFY2(zone.hasAlternativeName(id), zone.id() + " != " + id);
if (unAliasedLinks.find(id) == unAliasedLinks.end())
QVERIFY2(zone.hasAlternativeName(id), zone.id() + " != " + id);
}
// availableTimeZoneIds() doesn't list all possible offset IDs, but
// isTimeZoneIdAvailable() should accept them.
@ -995,7 +1019,8 @@ void tst_QTimeZone::stressTest()
for (const QByteArray &id : idList) {
QTimeZone testZone = QTimeZone(id);
QCOMPARE(testZone.isValid(), true);
QVERIFY2(testZone.hasAlternativeName(id), testZone.id() + " != " + id);
if (unAliasedLinks.find(id) == unAliasedLinks.end())
QVERIFY2(testZone.hasAlternativeName(id), testZone.id() + " != " + id);
QDateTime testDate = QDateTime(QDate(2015, 1, 1), QTime(0, 0), UTC);
testZone.territory();
testZone.comment();