Correct handling of 'u' in CLDR date format strings

It explicitly excludes having a two-digit special case like 'yy'.
Correct that in qlocale_mac.mm, add support in dateconverter.py
No current locale actually uses the 'u' format, so this makes no
change to data.

Change-Id: I16dfed2d3a7d2054b4b86f9a246bff297df9fc0a
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2024-04-03 19:13:23 +02:00
parent 42e4e1816a
commit b87db4296c
2 changed files with 11 additions and 1 deletions

View File

@ -344,7 +344,10 @@ static QVariant macToQtFormat(QStringView sys_fmt)
case 'Y': // Year for Week-of-year calendars (1..n): 1..n = padded number
break;
case 'u': // Extended Year (1..n): 2 = short year, 1 & 3..n = padded number
case 'u': // Extended Year (1..n), padded number.
// Explicitly has no special case for 'uu' as only the last two digits.
result += "yyyy"_L1;
break;
case 'y': // Year (1..n): 2 = short year, 1 & 3..n = padded number
// Qt only supports long (4) or short (2) year, use long for all others
if (repeat == 2)

View File

@ -100,6 +100,13 @@ class Converter (object):
n = cls.__count_first(text)
return ('z' if n < 3 else 'zzz'), n
@classmethod
def u(cls, text): # Extended year (numeric)
# Officially, 'u' is simply the full year number, zero-padded
# to the length of the field. Qt's closest to that is four-digit.
# It explicitly has no special case for two-digit year.
return 'yyyy', cls.__count_first(text)
# U: Cyclic Year Name. Not supported
@classmethod
def v(cls, text): # Generic non-location format. Map to abbreviation.