Skip to content

Commit

Permalink
CLDR-17827 check that intervalFormats pass DateIntervalInfo.genPatter…
Browse files Browse the repository at this point in the history
…nInfo; fix an,rif,si
  • Loading branch information
pedberg-icu committed Jul 24, 2024
1 parent b1ec8a6 commit 677e1d4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions common/main/an.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,8 @@ CLDR data files are interpreted according to the LDML specification (http://unic
</intervalFormatItem>
<intervalFormatItem id="yMEd">
<greatestDifference id="d" draft="unconfirmed">E, d/M/y – E, d/M/y</greatestDifference>
<greatestDifference id="M" draft="unconfirmed">E, d/M/y</greatestDifference>
<greatestDifference id="y" draft="unconfirmed">E, d/M/Y – E, d/M/Y</greatestDifference>
<greatestDifference id="M" draft="unconfirmed">E, d/M/y – E, d/M/y</greatestDifference>
<greatestDifference id="y" draft="unconfirmed">E, d/M/y – E, d/M/y</greatestDifference>
</intervalFormatItem>
<intervalFormatItem id="yMMM">
<greatestDifference id="M" draft="unconfirmed">LLL–LLL y</greatestDifference>
Expand Down
2 changes: 1 addition & 1 deletion common/main/rif.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ CLDR data files are interpreted according to the LDML specification (http://unic
</intervalFormatItem>
<intervalFormatItem id="MEd">
<greatestDifference id="d" draft="unconfirmed">E dd/MM – E dd/MM</greatestDifference>
<greatestDifference id="M" draft="unconfirmed">E dd/MM</greatestDifference>
<greatestDifference id="M" draft="unconfirmed">E dd/MM – E dd/MM</greatestDifference>
</intervalFormatItem>
<intervalFormatItem id="MMM">
<greatestDifference id="M" draft="unconfirmed">MMM – MMM</greatestDifference>
Expand Down
4 changes: 2 additions & 2 deletions common/main/si.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ Warnings: All cp values have U+FE0F characters removed. See /annotationsDerived/
<greatestDifference id="m">HH.mm–HH.mm</greatestDifference>
</intervalFormatItem>
<intervalFormatItem id="hmv">
<greatestDifference id="a">a h.mm – a hhh.mm v</greatestDifference>
<greatestDifference id="a">a h.mm – a h.mm v</greatestDifference>
<greatestDifference id="h">a h.mm – h.mm v</greatestDifference>
<greatestDifference id="m">a h.mm – h.mm v</greatestDifference>
</intervalFormatItem>
Expand All @@ -1193,7 +1193,7 @@ Warnings: All cp values have U+FE0F characters removed. See /annotationsDerived/
</intervalFormatItem>
<intervalFormatItem id="hv">
<greatestDifference id="a">a h – a h v</greatestDifference>
<greatestDifference id="h">a h – h vv</greatestDifference>
<greatestDifference id="h">a h – h v</greatestDifference>
</intervalFormatItem>
<intervalFormatItem id="Hv">
<greatestDifference id="H">↑↑↑</greatestDifference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.google.common.base.Joiner;
import com.ibm.icu.impl.Relation;
import com.ibm.icu.text.BreakIterator;
import com.ibm.icu.text.DateIntervalInfo;
import com.ibm.icu.text.DateIntervalInfo.PatternInfo;
import com.ibm.icu.text.DateTimePatternGenerator;
import com.ibm.icu.text.DateTimePatternGenerator.VariableField;
import com.ibm.icu.text.MessageFormat;
Expand Down Expand Up @@ -1192,6 +1194,33 @@ private void checkPattern(
new Object[] {requiredYearFieldCount, yearFieldCount}));
}
}
// check PatternInfo, for CLDR-17827
// ICU-22835, DateIntervalInfo.genPatternInfo fails for intervals like LLL - MMM (in fa)
if (!(value.contains("LLL") && value.contains("MMM"))) {
PatternInfo pattern = DateIntervalInfo.genPatternInfo(value, false);
try {
String first = pattern.getFirstPart();
String second = pattern.getSecondPart();
if (first == null || second == null) {
result.add(
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setSubtype(Subtype.incorrectDatePattern)
.setMessage(
"DateIntervalInfo.PatternInfo returns null for first or second part"));
}
} catch (Exception e) {
result.add(
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setSubtype(Subtype.incorrectDatePattern)
.setMessage(
"DateIntervalInfo.PatternInfo exception {0}",
new Object[] {e}));
}
}
}

if (value.contains("G") && calendar.equals("gregorian")) {
Expand Down

0 comments on commit 677e1d4

Please sign in to comment.