Fix handling of am/pm indicators in mapping from CLDR to Qt formats
Both qlocale_mac.mm and dateconverter.py were mapping the CLDR am/pm indicator, 'a', to the Qt format token 'AP', forcing the indicator to uppercase. The LDML spec [0] says: May be upper or lowercase depending on the locale and other options. [0] https://www.unicode.org/reports/tr35/tr35-68/tr35-dates.html#Date_Field_Symbol_Table We don't support the "other options" mentioned, but we can at least (since 6.3) preserve the the locale-appropriate case, instead of forcing upper-case. As such, this change is a follow-up to commit 4641ff0f6a1b0da6f55db5e33c58a77be2032808 Changes locale data, as expected, to use "Ap" in place of "AP" in various formats in the time_format_data[] array. [ChangeLog][QtCore][QLocale] Where CLDR specifies an am/pm indicator, the case of the CLDR-supplied indicator is used, where previously QLocale forced it to upper-case. Change-Id: Iee7d55e6f3c78372659668b9798c8e24a1fa8982 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d778d17b9f
commit
42e4e1816a
@ -2389,24 +2389,24 @@ static constexpr char16_t date_format_data[] = {
|
||||
|
||||
static constexpr char16_t time_format_data[] = {
|
||||
0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x74, 0x68, 0x3a,
|
||||
0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x202f, 0x41, 0x50, 0x20, 0x74, 0x68, 0x3a,
|
||||
0x6d, 0x6d, 0x202f, 0x41, 0x50, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73,
|
||||
0x202f, 0x41, 0x50, 0x2c, 0x20, 0x74, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73,
|
||||
0x73, 0x20, 0x41, 0x50, 0x20, 0x74, 0x68, 0x3a, 0x6d, 0x6d, 0x20, 0x41,
|
||||
0x50, 0x41, 0x50, 0x20, 0x68, 0x2e, 0x6d, 0x6d, 0x2e, 0x73, 0x73, 0x20,
|
||||
0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x202f, 0x41, 0x70, 0x20, 0x74, 0x68, 0x3a,
|
||||
0x6d, 0x6d, 0x202f, 0x41, 0x70, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73,
|
||||
0x202f, 0x41, 0x70, 0x2c, 0x20, 0x74, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73,
|
||||
0x73, 0x20, 0x41, 0x70, 0x20, 0x74, 0x68, 0x3a, 0x6d, 0x6d, 0x20, 0x41,
|
||||
0x70, 0x41, 0x70, 0x20, 0x68, 0x2e, 0x6d, 0x6d, 0x2e, 0x73, 0x73, 0x20,
|
||||
0x74, 0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x28, 0x74,
|
||||
0x29, 0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x2c, 0x20, 0x74,
|
||||
0x41, 0x50, 0x20, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x74,
|
||||
0x41, 0x50, 0x20, 0x928, 0x93f, 0x20, 0x68, 0x3a, 0x6d, 0x6d, 0x48, 0x3a,
|
||||
0x41, 0x70, 0x20, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x74,
|
||||
0x41, 0x70, 0x20, 0x928, 0x93f, 0x20, 0x68, 0x3a, 0x6d, 0x6d, 0x48, 0x3a,
|
||||
0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x27, 0x447, 0x27, 0x2e, 0x20, 0x74,
|
||||
0x74, 0x20, 0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x41, 0x50,
|
||||
0x74, 0x20, 0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x41, 0x70,
|
||||
0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x5b, 0x74, 0x5d, 0x74,
|
||||
0x20, 0x41, 0x50, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x48, 0x48,
|
||||
0x20, 0x41, 0x70, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x48, 0x48,
|
||||
0x2e, 0x6d, 0x6d, 0x2e, 0x73, 0x73, 0x20, 0x74, 0xf46, 0xf74, 0xf0b, 0xf5a,
|
||||
0xf7c, 0xf51, 0xf0b, 0x20, 0x68, 0x20, 0xf66, 0xf90, 0xf62, 0xf0b, 0xf58, 0xf0b,
|
||||
0x20, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x41, 0x50, 0x20, 0x74, 0xf46,
|
||||
0x20, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x41, 0x70, 0x20, 0x74, 0xf46,
|
||||
0xf74, 0xf0b, 0xf5a, 0xf7c, 0xf51, 0xf0b, 0x20, 0x68, 0x20, 0xf66, 0xf90, 0xf62,
|
||||
0xf0b, 0xf58, 0xf0b, 0x20, 0x6d, 0x6d, 0x20, 0x41, 0x50, 0x41, 0x50, 0x20,
|
||||
0xf0b, 0xf58, 0xf0b, 0x20, 0x6d, 0x6d, 0x20, 0x41, 0x70, 0x41, 0x70, 0x20,
|
||||
0x27, 0x67, 0x61, 0x27, 0x20, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73,
|
||||
0x20, 0x74, 0x48, 0x20, 0x27, 0x68, 0x27, 0x20, 0x6d, 0x6d, 0x20, 0x27,
|
||||
0x6d, 0x69, 0x6e, 0x27, 0x20, 0x73, 0x73, 0x20, 0x27, 0x73, 0x27, 0x20,
|
||||
@ -2414,22 +2414,22 @@ static constexpr char16_t time_format_data[] = {
|
||||
0x6d, 0x69, 0x6e, 0x27, 0x20, 0x73, 0x73, 0x20, 0x27, 0x73, 0x27, 0x20,
|
||||
0x74, 0x48, 0x48, 0x2e, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20, 0x27, 0x68,
|
||||
0x27, 0x20, 0x74, 0x68, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x20,
|
||||
0x41, 0x50, 0x20, 0x74, 0x68, 0x68, 0x3a, 0x6d, 0x6d, 0x20, 0x41, 0x50,
|
||||
0x48, 0x6642, 0x6d, 0x6d, 0x5206, 0x73, 0x73, 0x79d2, 0x20, 0x74, 0x41, 0x50,
|
||||
0x41, 0x70, 0x20, 0x74, 0x68, 0x68, 0x3a, 0x6d, 0x6d, 0x20, 0x41, 0x70,
|
||||
0x48, 0x6642, 0x6d, 0x6d, 0x5206, 0x73, 0x73, 0x79d2, 0x20, 0x74, 0x41, 0x70,
|
||||
0x20, 0x68, 0xc2dc, 0x20, 0x6d, 0xbd84, 0x20, 0x73, 0xcd08, 0x20, 0x74, 0x48,
|
||||
0x20, 0xec2, 0xea1, 0xe87, 0x20, 0x6d, 0x20, 0xe99, 0xeb2, 0xe97, 0xeb5, 0x20,
|
||||
0x73, 0x73, 0x20, 0xea7, 0xeb4, 0xe99, 0xeb2, 0xe97, 0xeb5, 0x20, 0x74, 0x27,
|
||||
0x4b, 0x6c, 0x6f, 0x63, 0x6b, 0x27, 0x20, 0x48, 0x2e, 0x6d, 0x6d, 0x3a,
|
||||
0x73, 0x73, 0x20, 0x28, 0x74, 0x29, 0x27, 0x4b, 0x6c, 0x27, 0x2e, 0x20,
|
||||
0x48, 0x2e, 0x6d, 0x6d, 0x68, 0x2e, 0x6d, 0x6d, 0x2e, 0x73, 0x73, 0x20,
|
||||
0x41, 0x50, 0x20, 0x74, 0x68, 0x2e, 0x6d, 0x6d, 0x2e, 0x20, 0x41, 0x50,
|
||||
0x41, 0x70, 0x20, 0x74, 0x68, 0x2e, 0x6d, 0x6d, 0x2e, 0x20, 0x41, 0x70,
|
||||
0x27, 0x6b, 0x6c, 0x27, 0x2e, 0x20, 0x48, 0x48, 0x3a, 0x6d, 0x6d, 0x3a,
|
||||
0x73, 0x73, 0x20, 0x74, 0x74, 0x20, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73,
|
||||
0x73, 0x202f, 0x41, 0x50, 0x48, 0x27, 0x68, 0x27, 0x6d, 0x6d, 0x48, 0x20,
|
||||
0x73, 0x202f, 0x41, 0x70, 0x48, 0x27, 0x68, 0x27, 0x6d, 0x6d, 0x48, 0x20,
|
||||
0xe19, 0xe32, 0xe2c, 0xe34, 0xe01, 0xe32, 0x20, 0x6d, 0x6d, 0x20, 0xe19, 0xe32,
|
||||
0xe17, 0xe35, 0x20, 0x73, 0x73, 0x20, 0xe27, 0xe34, 0xe19, 0xe32, 0xe17, 0xe35,
|
||||
0x20, 0x74, 0x68, 0x68, 0x3a, 0x6d, 0x6d, 0x3a, 0x73, 0x73, 0x202f, 0x41,
|
||||
0x50, 0x20, 0x74, 0x68, 0x68, 0x3a, 0x6d, 0x6d, 0x202f, 0x41, 0x50, 0x48,
|
||||
0x70, 0x20, 0x74, 0x68, 0x68, 0x3a, 0x6d, 0x6d, 0x202f, 0x41, 0x70, 0x48,
|
||||
0x3a, 0x6d, 0x6d, 0x20, 0x27, 0x68, 0x6f, 0x64, 0x17a, 0x27, 0x2e
|
||||
};
|
||||
|
||||
|
@ -376,8 +376,8 @@ static QVariant macToQtFormat(QStringView sys_fmt)
|
||||
case 'a': // AM/PM (1..n): Qt supports no distinctions
|
||||
case 'b': // Like a, but also distinguishing noon, midnight (ignore difference).
|
||||
case 'B': // Flexible day period (at night, &c.)
|
||||
// Translate to Qt uppercase AM/PM
|
||||
result += "AP"_L1;
|
||||
// Translate to Qt AM/PM, using locale-appropriate case:
|
||||
result += "Ap"_L1;
|
||||
break;
|
||||
case 'h': // Hour [1..12] (1,2): 1,2 = padded number
|
||||
case 'K': // Hour [0..11] (1,2): 1,2 = padded number
|
||||
|
@ -3341,10 +3341,10 @@ void tst_QLocale::timeFormat()
|
||||
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:
|
||||
// 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);
|
||||
QCOMPARE(tw.timeFormat(QLocale::ShortFormat), "Aph:mm"_L1);
|
||||
QCOMPARE(tw.timeFormat(QLocale::LongFormat), "Aph:mm:ss [t]"_L1);
|
||||
}
|
||||
|
||||
void tst_QLocale::dateTimeFormat()
|
||||
|
@ -39,8 +39,8 @@ class Converter (object):
|
||||
# Please follow alphabetic order, with two cases of the same
|
||||
# letter adjacent, lower before upper.
|
||||
@classmethod
|
||||
def a(cls, text): # AM/PM indicator
|
||||
return 'AP', cls.__count_first(text)
|
||||
def a(cls, text): # AM/PM indicator; use locale-appropriate case
|
||||
return 'Ap', cls.__count_first(text)
|
||||
|
||||
# A: Milliseconds in day. Not supported.
|
||||
b = a # AM/PM/noon/midnight
|
||||
|
Loading…
x
Reference in New Issue
Block a user