summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2024-04-02 20:40:33 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2024-04-19 13:39:40 +0200
commitd778d17b9f023e115dfbaa4bbd7255b52f41e67f (patch)
tree0ec6a6d4fc6005205285800feac9bca54c186bab /tests/auto
parentea806fa3f15061d75d2c2c40144588053e2217b0 (diff)
Cope with CLDR's "day period" format specifiers
The LDML spec includes a 'b' pattern character which is like the 'a' pattern, for AM and PM, but would rather use noon and midnight indicators for those specific times. We don't support those and using am/pm will be right enough of the time to be better than simply discarding this option, if it ever gets used (which it currently isn't), so treat as an alias for 'a'. No locale in CLDR currently uses this. CLDR also has a 'B' specifiers for "flexible day periods", including things like "at night" and "in the day". At present only zh_Hant uses 'B'. As a result, this change only affects zh_Hant's formats for time and datetime, which only zh_Hant_TW uses - zh_Hant_HK overrides them to use am/pm markers and zh_Hant_MO inherits that from zh_Hant_HK. Based on this and user feed-back, I've opted to treat 'B' as another synonym of 'a'. This removes an entry from the time_format_data[] table (it happened to occupy one whole twelve-character row), causing many other locales' offsets into that table to be shifted by 12. Only zh_Hant_TW has an actual change to which entry in the table it uses. Added a test-case. [ChangeLog][QtCore][QLocale] CLDR's 'B' (flexible day period, e.g. "at night" &c.) field, not currently supported, is now handled as a synonym for the AM/PM field 'a', instead of leaving the B as literal text. Only affects zh_TW at present. Fixes: QTBUG-123872 Change-Id: I6ba008c0a048190bf7af8c7df7629a885b05804f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index c5397e384b..872c9f115b 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -3340,6 +3340,11 @@ void tst_QLocale::timeFormat()
const QLocale bra("pt_BR");
QCOMPARE(bra.timeFormat(QLocale::ShortFormat), QLatin1String("HH:mm"));
QCOMPARE(bra.timeFormat(QLocale::LongFormat), QLatin1String("HH:mm:ss t"));
+
+ // QTBUG-123872 - we kludge CLDR's B to AP:
+ const QLocale tw("zh_TW");
+ QCOMPARE(tw.timeFormat(QLocale::ShortFormat), "APh:mm"_L1);
+ QCOMPARE(tw.timeFormat(QLocale::LongFormat), "APh:mm:ss [t]"_L1);
}
void tst_QLocale::dateTimeFormat()