Skip to content

Commit 800d935

Browse files
committed
ICU-23199 Using 'C' in skeleton throws for some locales
1 parent cd47835 commit 800d935

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

icu4c/source/test/intltest/dtptngts.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,8 @@ void IntlTestDateTimePatternGeneratorAPI::testC() {
11591159
{"en", "CCCCCCm", "hh:mm\\u202Faaaaa"},
11601160
{"en-BN", "Cm", "h:mm\\u202Fb"},
11611161
{"gu-IN", "Cm", "h:mm B"},
1162-
{"und-IN", "Cm", "h:mm B"}
1162+
{"und-IN", "Cm", "h:mm B"},
1163+
{"fi", "Cm", "H.mm"}
11631164
};
11641165

11651166
UErrorCode status = U_ZERO_ERROR;

icu4j/main/core/src/main/java/com/ibm/icu/text/DateTimePatternGenerator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,11 @@ private void getAllowedHourFormats(ULocale uLocale) {
423423

424424
if (list != null) {
425425
defaultHourFormatChar = defaultCharFromLocale != null ? defaultCharFromLocale : list[0].charAt(0);
426-
allowedHourFormats = Arrays.copyOfRange(list, 1, list.length - 1);
426+
if (list.length > 1) {
427+
allowedHourFormats = Arrays.copyOfRange(list, 1, list.length);
428+
} else {
429+
allowedHourFormats = LAST_RESORT_ALLOWED_HOUR_FORMAT;
430+
}
427431
} else {
428432
allowedHourFormats = LAST_RESORT_ALLOWED_HOUR_FORMAT;
429433
defaultHourFormatChar = (defaultCharFromLocale != null) ? defaultCharFromLocale : allowedHourFormats[0].charAt(0);

icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public void TestC() {
7777
{"en-BN", "Cm", "h:mm\u202Fb"},
7878
{"gu-IN", "Cm", "h:mm B"},
7979
{"und-IN", "Cm", "h:mm B"},
80+
{"fi", "Cm", "H.mm"},
8081
};
8182
for (String[] test : tests) {
8283
DateTimePatternGenerator gen = DateTimePatternGenerator.getInstance(ULocale.forLanguageTag(test[0]));

0 commit comments

Comments
 (0)