Skip to content

Commit

Permalink
CLDR-15698 Time examples < 10 and > 12
Browse files Browse the repository at this point in the history
See #3895
  • Loading branch information
Emiyare Ikwut-Ukwa authored and Squash Bot committed Jul 26, 2024
1 parent 43b30f7 commit 4083bf7
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public class ExampleGenerator {
private static final Date DATE_SAMPLE2;
private static final Date DATE_SAMPLE3;
private static final Date DATE_SAMPLE4;
private static final Date DATE_SAMPLE5; // 15698

static {
Calendar calendar = Calendar.getInstance(ZONE_SAMPLE, ULocale.ENGLISH);
Expand All @@ -182,6 +183,9 @@ public class ExampleGenerator {
DATE_SAMPLE3 = calendar.getTime();
calendar.set(1999, 8, 5, 23, 0, 0); // 1999-09-05 23:00:00
DATE_SAMPLE4 = calendar.getTime();

calendar.set(1999, 8, 5, 3, 25, 59); // 1999-09-05 03:25:59 15698
DATE_SAMPLE5 = calendar.getTime(); // 15698
}

static final List<DecimalQuantity> CURRENCY_SAMPLES =
Expand Down Expand Up @@ -2513,7 +2517,7 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont
setBackground("'" + tlfResult + "'"),
setBackground("'" + dfResult + "'")
}));
examples.add(dtf.format(DATE_SAMPLE));
examples.add(dtf.format(DATE_SAMPLE)); // 15698: "full time" -- 2 examples?

// Handle date plus a single short time.
dtf =
Expand All @@ -2526,7 +2530,7 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont
setBackground("'" + tsfResult + "'"),
setBackground("'" + dfResult + "'")
}));
examples.add(dtf.format(DATE_SAMPLE));
examples.add(dtf.format(DATE_SAMPLE)); // 15698: "short time" -- 2 examples?

if (!formatType.contentEquals("atTime")) {
// Examples for standard pattern
Expand Down Expand Up @@ -2556,7 +2560,7 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont
setBackground("'" + timeRange + "'"),
setBackground("'" + dfResult + "'")
}));
examples.add(dtf.format(DATE_SAMPLE));
examples.add(dtf.format(DATE_SAMPLE)); // 15698: don't need two times for range

// Handle relative date plus short time range
dtf =
Expand All @@ -2569,7 +2573,7 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont
setBackground("'" + timeRange + "'"),
setBackground("'" + relativeDayValue + "'")
}));
examples.add(dtf.format(DATE_SAMPLE));
examples.add(dtf.format(DATE_SAMPLE)); // 15698: don't need two times for range
}
} else {
// Examples for atTime pattern
Expand All @@ -2585,14 +2589,14 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont
setBackground("'" + tsfResult + "'"),
setBackground("'" + relativeDayValue + "'")
}));
examples.add(dtf.format(DATE_SAMPLE));
examples.add(dtf.format(DATE_SAMPLE)); // 15698: "short time" -- 2 examples?
}

return formatExampleList(examples.toArray(new String[0]));
} else {
String id = parts.findAttributeValue("dateFormatItem", "id");
if ("NEW".equals(id) || value == null) {
return startItalicSymbol + "n/a" + endItalicSymbol;
return startItalicSymbol + "n/a" + endItalicSymbol; // 15698: doesn't seem relevant--meaning??
} else {
String numbersOverride = parts.findAttributeValue("pattern", "numbers");
SimpleDateFormat sdf =
Expand All @@ -2615,16 +2619,21 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont
return sdf.format(DATE_SAMPLE);
} else {
// Use contextExamples if showContexts T
String example =
String example = // 15698 clarification: what does this do, and why only do it here?
showContexts
? exampleStartHeaderSymbol
+ contextheader
+ exampleEndSymbol
: "";
example = addExampleResult(sdf.format(DATE_SAMPLE), example, showContexts);
return example;
String sup_twelve_example = sdf.format(DATE_SAMPLE); // 15698
String sub_ten_example = sdf.format(DATE_SAMPLE5); // 15698 (is it bad that these aren't chronological? idk if there's any significance to DATE_SAMPLE)
example = addExampleResult(sup_twelve_example, example, showContexts); // 15698, here the task is clear
if (!sup_twelve_example.equals(sub_ten_example)) {
example = addExampleResult(sub_ten_example, example, showContexts); // 15698 should maybe use formatExampleList, but confused about above example declaration
}
return example; // 15698
}
} else {
} else { // 15698 id contains B suggests it contains time of day, ignore?
List<String> examples = new ArrayList<>();
examples.add(sdf.format(DATE_SAMPLE3));
examples.add(sdf.format(DATE_SAMPLE));
Expand Down

0 comments on commit 4083bf7

Please sign in to comment.