Skip to content

Commit

Permalink
CLDR-10347 Updated using style feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
haytenf committed Aug 9, 2024
1 parent cf294f0 commit 8cc6f65
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public class ExampleGenerator {

private static final Date DATE_SAMPLE2;
private static final Date DATE_SAMPLE3;
private static final Date DATE_SAMPLE4;

static {
Calendar calendar = Calendar.getInstance(ZONE_SAMPLE, ULocale.ENGLISH);
Expand All @@ -180,8 +179,6 @@ public class ExampleGenerator {

calendar.set(1999, 8, 5, 7, 0, 0); // 1999-09-05 07:00:00
DATE_SAMPLE3 = calendar.getTime();
calendar.set(1999, 8, 5, 23, 0, 0); // 1999-09-05 23:00:00
DATE_SAMPLE4 = calendar.getTime();
}

static final List<DecimalQuantity> CURRENCY_SAMPLES =
Expand Down Expand Up @@ -2634,8 +2631,8 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont
}
R3<Integer, Integer, Boolean> info = dayPeriodInfo.getFirstDayPeriodInfo(dayPeriod);
if (info != null) {
int time = ((info.get0() + info.get1()) / 2); // time midpoint
String formatted = sdf.format(time);
int time = ((info.get0() + info.get1()) / 2); // dayPeriod endpoints overlap, midpoint to disambiguate
String formatted = sdf.format(time);
examples.add(formatted);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1123,54 +1123,40 @@ private void checkDayPeriod(
checkPathValue(exampleGenerator, path, cldrFile.getStringValue(path), expected);
}

public void TestAllDayPeriods() {
// excludes midnight, see ICU-12278
String[][] tests = {
{
"en",
"//ldml/dates/calendars/calendar"
+ "[@type=\"gregorian\"]/dateTimeFormats/"
+ "availableFormats/dateFormatItem"
+ "[@id=\"Bhm\"]",
"en day periods pattern \"Bhm\"",
"〖3:00 at night〗〖9:00 in the morning〗〖12:00 noon〗〖3:00 in the afternoon〗〖7:30 in the evening〗"
},
{
"it",
"//ldml/dates/calendars/calendar"
+ "[@type=\"gregorian\"]/dateTimeFormats/"
+ "availableFormats/dateFormatItem"
+ "[@id=\"Bhm\"]",
"it day periods pattern \"Bhm\"",
"〖3:00 di notte〗〖9:00 di mattina〗〖12:00 mezzogiorno〗〖3:00 di pomeriggio〗〖9:00 di sera〗"
},
{
"de",
"//ldml/dates/calendars/calendar"
+ "[@type=\"gregorian\"]/dateTimeFormats/"
+ "availableFormats/dateFormatItem"
+ "[@id=\"Bhm\"]",
"de day periods pattern \"Bhm\"",
"〖2:30 nachts〗〖7:30 morgens〗〖11:00 vorm.〗〖12:30 mittags〗〖3:30 nachm.〗〖9:00 abends〗"
},
{
"zh",
"//ldml/dates/calendars/calendar"
+ "[@type=\"gregorian\"]/dateTimeFormats/"
+ "availableFormats/dateFormatItem"
+ "[@id=\"Bhm\"]",
"zh day periods pattern \"Bhm\"",
"〖凌晨2:30〗〖早上6:30〗〖上午10:00〗〖中午12:30〗〖下午4:00〗〖晚上9:30〗"
},
};
for (String[] test : tests) {
final String locale = test[0];
final String path = test[1];
final String message = test[2];
final String expected = test[3];
ExampleGenerator exampleGenerator = getExampleGenerator(locale);
checkValue(message, expected, exampleGenerator, path);
}
public void TestAllDayPeriods() { // excludes midnight, see ICU-12278
checkDayPeriodsForLocale(
"en",
"Bhm",
"〖3:00 at night〗〖9:00 in the morning〗〖12:00 noon〗〖3:00 in the afternoon〗〖7:30 in the evening〗");
checkDayPeriodsForLocale(
"it",
"Bhm",
"〖3:00 di notte〗〖9:00 di mattina〗〖12:00 mezzogiorno〗〖3:00 di pomeriggio〗〖9:00 di sera〗");
checkDayPeriodsForLocale(
"de",
"Bhm",
"〖2:30 nachts〗〖7:30 morgens〗〖11:00 vorm.〗〖12:30 mittags〗〖3:30 nachm.〗〖9:00 abends〗");
checkDayPeriodsForLocale(
"zh",
"Bhm",
"〖凌晨2:30〗〖早上6:30〗〖上午10:00〗〖中午12:30〗〖下午4:00〗〖晚上9:30〗");
checkDayPeriodsForLocale(
"am",
"EBhm",
"〖ሐሙስ በሌሊት 3:00〗〖ሐሙስ ጥዋት 9:00〗〖ሐሙስ ቀትር 12:00〗〖ሐሙስ ከሰዓት 3:00〗〖ሐሙስ በምሽት 9:00〗");
checkDayPeriodsForLocale(
"hi",
"EBhms",
"〖गुरु रात 2:00:00〗〖गुरु सुबह 8:00:00〗〖गुरु दोपहर 2:00:00〗〖गुरु शाम 6:00:00〗");
}

public void checkDayPeriodsForLocale(String localeId, String pattern, String expected) {
ExampleGenerator exampleGenerator = getExampleGenerator(localeId);
String path = "//ldml/dates/calendars/calendar[@type=\"gregorian\"]"
+ "/dateTimeFormats/availableFormats/dateFormatItem"
+ "[@id=\"" + pattern + "\"]";
String message = "Day periods with pattern \"" + pattern + "\"";
checkValue(message, expected, exampleGenerator, path);
}

/**
Expand Down

0 comments on commit 8cc6f65

Please sign in to comment.