Skip to content

Commit

Permalink
Cope with IANA DB links that aren't in the CLDR alias mapping
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit ae6b6bf)
  • Loading branch information
ediosyncratic committed Dec 11, 2024
1 parent dff71f5 commit 2fa5a52
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <QOperatingSystemVersion>
#endif

#include <set>

#if defined(Q_OS_WIN) && !QT_CONFIG(icu)
# define USING_WIN_TZ
#endif
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2fa5a52

Please sign in to comment.