Skip to content

Instantly share code, notes, and snippets.

@anba

anba/patch.diff Secret

Created February 24, 2020 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anba/5813c6c87b992a2c9b9eabe84c09e5dd to your computer and use it in GitHub Desktop.
Save anba/5813c6c87b992a2c9b9eabe84c09e5dd to your computer and use it in GitHub Desktop.
Patch ICU-20739, ICU-20992, CLDR-13184, CLDR-13623
diff --git a/icu4c/source/data/locales/root.txt b/icu4c/source/data/locales/root.txt
index 5ae5c3e..dd43302 100644
--- a/icu4c/source/data/locales/root.txt
+++ b/icu4c/source/data/locales/root.txt
@@ -218,6 +218,7 @@ root{
NoonMarkerNarrow:alias{"/LOCALE/calendar/gregorian/NoonMarkerNarrow"}
appendItems{
Day{"{0} ({2}: {1})"}
+ DayPeriod{"{0} ({2}: {1})"}
Day-Of-Week{"{0} {1}"}
Era{"{1} {0}"}
Hour{"{0} ({2}: {1})"}
@@ -225,6 +226,7 @@ root{
Month{"{0} ({2}: {1})"}
Quarter{"{0} ({2}: {1})"}
Second{"{0} ({2}: {1})"}
+ FractionalSecond{"{0} ({2}: {1})"}
Timezone{"{0} {1}"}
Week{"{0} ({2}: {1})"}
Year{"{1} {0}"}
@@ -754,6 +756,7 @@ root{
NoonMarkerNarrow:alias{"/LOCALE/calendar/gregorian/NoonMarkerNarrow"}
appendItems{
Day{"{0} ({2}: {1})"}
+ DayPeriod{"{0} ({2}: {1})"}
Day-Of-Week{"{0} {1}"}
Era{"{1} {0}"}
Hour{"{0} ({2}: {1})"}
@@ -761,6 +764,7 @@ root{
Month{"{0} ({2}: {1})"}
Quarter{"{0} ({2}: {1})"}
Second{"{0} ({2}: {1})"}
+ FractionalSecond{"{0} ({2}: {1})"}
Timezone{"{0} {1}"}
Week{"{0} ({2}: {1})"}
Year{"{1} {0}"}
@@ -1023,6 +1027,7 @@ root{
}
appendItems{
Day{"{0} ({2}: {1})"}
+ DayPeriod{"{0} ({2}: {1})"}
Day-Of-Week{"{0} {1}"}
Era{"{1} {0}"}
Hour{"{0} ({2}: {1})"}
@@ -1030,6 +1035,7 @@ root{
Month{"{0} ({2}: {1})"}
Quarter{"{0} ({2}: {1})"}
Second{"{0} ({2}: {1})"}
+ FractionalSecond{"{0} ({2}: {1})"}
Timezone{"{0} {1}"}
Week{"{0} ({2}: {1})"}
Year{"{1} {0}"}
@@ -2532,6 +2538,11 @@ root{
}
zone-narrow:alias{"/LOCALE/fields/zone-short"}
zone-short:alias{"/LOCALE/fields/zone"}
+ fractionalSecond{
+ dn{"Fractional Second"}
+ }
+ fractionalSecond-narrow:alias{"/LOCALE/fields/fractionalSecond-short"}
+ fractionalSecond-short:alias{"/LOCALE/fields/fractionalSecond"}
}
layout{
characters{"left-to-right"}
diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp
index af92b78..76b015b 100644
--- a/icu4c/source/i18n/dtptngen.cpp
+++ b/icu4c/source/i18n/dtptngen.cpp
@@ -259,14 +259,14 @@ static const dtTypeElem dtTypes[] = {
static const char* const CLDR_FIELD_APPEND[] = {
"Era", "Year", "Quarter", "Month", "Week", "*", "Day-Of-Week",
- "*", "*", "Day", "*", // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J
- "Hour", "Minute", "Second", "*", "Timezone"
+ "*", "*", "Day", "DayPeriod", // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J
+ "Hour", "Minute", "Second", "FractionalSecond", "Timezone"
};
static const char* const CLDR_FIELD_NAME[UDATPG_FIELD_COUNT] = {
"era", "year", "quarter", "month", "week", "weekOfMonth", "weekday",
"dayOfYear", "weekdayOfMonth", "day", "dayperiod", // The UDATPG_x_FIELD constants and these fields have a different order than in ICU4J
- "hour", "minute", "second", "*", "zone"
+ "hour", "minute", "second", "fractionalSecond", "zone"
};
static const char* const CLDR_FIELD_WIDTH[] = { // [UDATPG_WIDTH_COUNT]
@@ -949,6 +949,15 @@ struct DateTimePatternGenerator::AppendItemNamesSink : public ResourceSink {
UDateTimePGDisplayWidth width;
UDateTimePatternField field = dtpg.getFieldAndWidthIndices(key, &width);
if (field == UDATPG_FIELD_COUNT) { continue; }
+
+ UResType type = value.getType();
+ U_ASSERT(type == URES_TABLE || type == URES_ALIAS);
+
+ // TODO: Implement support for alias types.
+ if (type == URES_ALIAS) {
+ continue;
+ }
+
ResourceTable detailsTable = value.getTable(errorCode);
if (U_FAILURE(errorCode)) { return; }
for (int32_t j = 0; detailsTable.getKeyAndValue(j, key, value); ++j) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment