ICU-20408 Integrate jpanyear support and related "ja" format changes [& resolve conflicts] (#465)

This commit is contained in:
Peter Edberg 2019-02-21 11:44:16 -08:00 committed by pedberg-icu
parent 4f20fea3ba
commit 2c1fcb0a96
15 changed files with 169 additions and 50 deletions

File diff suppressed because one or more lines are too long

View file

@ -1117,6 +1117,7 @@ en{
java{"Javanese Digits"}
jpan{"Japanese Numerals"}
jpanfin{"Japanese Financial Numerals"}
jpanyear{"Japanese Calendar Gannen Year Numerals"}
kali{"Kayah Li Digits"}
khmr{"Khmer Digits"}
knda{"Kannada Digits"}

View file

@ -1162,8 +1162,8 @@ ja{
"H:mm",
"Gy年M月d日(EEEE)",
"Gy年M月d日",
"Gy/MM/dd",
"Gy/M/d",
"GGGGGy/MM/dd",
"GGGGGy/M/d",
"{1} {0}",
"{1} {0}",
"{1} {0}",
@ -1207,33 +1207,50 @@ ja{
ms{"mm:ss"}
y{"Gy年"}
yyyy{"Gy年"}
yyyyM{"Gy/M"}
yyyyMEEEEd{"Gy/M/d(EEEE)"}
yyyyMEd{"Gy/M/d(E)"}
yyyyM{"GGGGGy/M"}
yyyyMEEEEd{"GGGGGy/M/d(EEEE)"}
yyyyMEd{"GGGGGy/M/d(E)"}
yyyyMMM{"Gy年M月"}
yyyyMMMEEEEd{"Gy年M月d日(EEEE)"}
yyyyMMMEd{"Gy年M月d日(E)"}
yyyyMMMM{"Gy年M月"}
yyyyMMMd{"Gy年M月d日"}
yyyyMd{"Gy/M/d"}
yyyyMd{"GGGGGy/M/d"}
yyyyQQQ{"Gy/QQQ"}
yyyyQQQQ{"Gy年QQQQ"}
}
intervalFormats{
GGGGGyM{
G{"GGGGGy/MMGGGGGy/MM"}
M{"GGGGGy/MMy/MM"}
y{"GGGGGy/MMy/MM"}
}
GGGGGyMEd{
G{"GGGGGy/MM/dd(E)GGGGGy/MM/dd(E)"}
M{"GGGGGy/MM/dd(E)y/MM/dd(E)"}
d{"GGGGGy/MM/dd(E)y/MM/dd(E)"}
y{"GGGGGy/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"}
M{"GGGGGy/MM/dd(E)y/MM/dd(E)"}
d{"GGGGGy/MM/dd(E)y/MM/dd(E)"}
y{"GGGGGy/MM/dd(E)y/MM/dd(E)"}
}
yMMM{
M{"Gy年M月M月"}
@ -1350,9 +1367,9 @@ ja{
y{"Gy年M月d日y年M月d日"}
}
yMd{
M{"Gy/MM/ddy/MM/dd"}
d{"Gy/MM/ddy/MM/dd"}
y{"Gy/MM/ddy/MM/dd"}
M{"GGGGGy/MM/ddy/MM/dd"}
d{"GGGGGy/MM/ddy/MM/dd"}
y{"GGGGGy/MM/ddy/MM/dd"}
}
}
}
@ -2253,9 +2270,18 @@ ja{
"H:mm:ss z",
"H:mm:ss",
"H:mm",
"Gy年M月d日EEEE",
"Gy年M月d日",
"Gy年M月d日",
{
"Gy年M月d日EEEE",
"y=jpanyear",
}
{
"Gy年M月d日",
"y=jpanyear",
}
{
"Gy年M月d日",
"y=jpanyear",
}
"GGGGGy/M/d",
"{1} {0}",
"{1} {0}",
@ -2291,16 +2317,16 @@ ja{
ms{"mm:ss"}
y{"Gy年"}
yyyy{"Gy年"}
yyyyM{"Gy/M"}
yyyyMEEEEd{"Gy/M/dEEEE"}
yyyyMEd{"Gy/M/d(E)"}
yyyyMM{"Gy/MM"}
yyyyM{"GGGGGy/M"}
yyyyMEEEEd{"GGGGGy/M/dEEEE"}
yyyyMEd{"GGGGGy/M/d(E)"}
yyyyMM{"GGGGGy/MM"}
yyyyMMM{"Gy年M月"}
yyyyMMMEEEEd{"Gy年M月d日EEEE"}
yyyyMMMEd{"Gy年M月d日(E)"}
yyyyMMMM{"Gy年M月"}
yyyyMMMd{"Gy年M月d日"}
yyyyMd{"Gy/M/d"}
yyyyMd{"GGGGGy/M/d"}
yyyyQQQ{"Gy/QQQ"}
yyyyQQQQ{"Gy年QQQQ"}
}

View file

@ -631,6 +631,7 @@ keyTypeData:table(nofallback){
java{""}
jpan{""}
jpanfin{""}
jpanyear{""}
kali{""}
khmr{""}
knda{""}

View file

@ -172,6 +172,11 @@ numberingSystems:table(nofallback){
desc{"ja/SpelloutRules/%spellout-cardinal-financial"}
radix:int{10}
}
jpanyear{
algorithmic:int{1}
desc{"ja/SpelloutRules/%spellout-numbering-year-latn"}
radix:int{10}
}
kali{
algorithmic:int{0}
desc{"꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉"}

View file

@ -8,6 +8,11 @@ ja{
"0: \u7B2C=#,##0=;",
}
SpelloutRules{
"%spellout-numbering-year-latn:",
"x.x: =0.0=;",
"0: =0=;",
"1: \u5143;",
"2: =0=;",
"%spellout-numbering-year:",
"x.x: =0.0=;",
"0: =%spellout-numbering=;",
@ -73,5 +78,5 @@ ja{
"0: \u7B2C=%spellout-numbering=;",
}
}
Version{"2.1.27.22"}
Version{"2.1.48.72"}
}

View file

@ -204,9 +204,9 @@ void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
UnicodeString("23:58"), // 16: JJmm
// ja@calendar=japanese // 6 ja@calendar=japanese
CharsToUnicodeString("\\u5E73\\u621011/1"), // 00: yM -> Gy/m
UnicodeString("H11/1"), // 00: yM -> GGGGGy/m
CharsToUnicodeString("\\u5E73\\u621011\\u5E741\\u6708"), // 01: yMMM -> Gy\u5E74M\u6708
CharsToUnicodeString("\\u5E73\\u621011/1/13"), // 02: yMd -> Gy/m/d
UnicodeString("H11/1/13"), // 02: yMd -> GGGGGy/m/d
CharsToUnicodeString("\\u5E73\\u621011\\u5E741\\u670813\\u65E5"), // 03: yMMMd -> Gy\u5E74M\u6708d\u65E5
UnicodeString("1/13"), // 04: Md -> M/d
CharsToUnicodeString("1\\u670813\\u65E5"), // 05: MMMd -> M\u6708d\u65E5

View file

@ -597,6 +597,15 @@ void IntlCalendarTest::TestJapaneseFormat() {
status = U_ZERO_ERROR;
simpleTest(loc, expect, expectDate, status);
}
{ // 1989 Jan 9 Monday = Heisei 1; full is Gy年M月d日EEEE => 平成元年1月9日月曜日
UnicodeString expect = CharsToUnicodeString("\\u5E73\\u6210\\u5143\\u5E741\\u67089\\u65E5\\u6708\\u66DC\\u65E5");
UDate expectDate = 600336000000.0;
Locale loc("ja_JP@calendar=japanese");
status = U_ZERO_ERROR;
simpleTest(loc, expect, expectDate, status);
}
{ // This Feb 29th falls on a leap year by gregorian year, but not by Japanese year.
UnicodeString expect = CharsToUnicodeString("\\u5EB7\\u6B632\\u5e742\\u670829\\u65e5\\u65e5\\u66dc\\u65e5");

View file

@ -24440,6 +24440,23 @@ structLocale:table(nofallback){
}
}
intervalFormats{
GGGGGyM{
G{""}
M{""}
y{""}
}
GGGGGyMEd{
G{""}
M{""}
d{""}
y{""}
}
GGGGGyMd{
G{""}
M{""}
d{""}
y{""}
}
Gy{
G{""}
y{""}
@ -26377,10 +26394,10 @@ structLocale:table(nofallback){
"",
"",
"",
"",
"",
"",
"",
"A2",
"A2",
"A2",
"A2",
"",
"A4",
"A4",

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0d98156c68867e10e71d59549cb054852ed6a935bf1e2db86b09febc491fdbd6
size 12698093
oid sha256:621340542b71db82df705396198ca290f90eaae84b582bd6189db2254d8b1de0
size 13931638

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:00ce84fd2fa0a741f07cab7bb17a86e70430be09bbc43f01fcc4f29a06eca2ee
size 725933
oid sha256:8aada92c658887d85f4280119d03736edf393efe5d33509b1e3bcb2b7809e58f
size 723108

View file

@ -152,11 +152,11 @@ public class JapaneseTest extends CalendarTestFmwk {
{
ULocale loc = new ULocale("ja_JP@calendar=japanese");
Calendar cal = new JapaneseCalendar(loc);
DateFormat enjformat = cal.getDateTimeFormat(0,0,new ULocale("en_JP@calendar=japanese"));
DateFormat format = cal.getDateTimeFormat(0,0,loc);
DateFormat enjformat = cal.getDateTimeFormat(DateFormat.FULL,DateFormat.FULL,new ULocale("en_JP@calendar=japanese"));
DateFormat format = cal.getDateTimeFormat(DateFormat.SHORT,DateFormat.SHORT,loc); // SHORT => no jpanyear since we apply "y.M.d" anyway
((SimpleDateFormat)format).applyPattern("y.M.d"); // Note: just 'y' doesn't work here.
ParsePosition pos = new ParsePosition(0);
Date aDate = format.parse("1.1.9", pos); // after the start of heisei accession. Jan 1, 1H wouldn't work because it is actually showa 64
Date aDate = format.parse("1.5.9", pos); // after accession (Heisei or next). Before accession in the same year would format with the previous era.
String inEn = enjformat.format(aDate);
cal.clear();
@ -204,6 +204,27 @@ public class JapaneseTest extends CalendarTestFmwk {
} else {
logln(" year: " + gotYear + ", era: " + gotEra);
}
// Tests for formats with gannen numbering Gy年
pos.setIndex(0);
aDate = format.parse("1.5.9", pos); // reset
DateFormat fmtWithGannen = DateFormat.getDateInstance(cal, DateFormat.MEDIUM, loc);
String aString = fmtWithGannen.format(aDate);
if (aString.charAt(2) != '\u5143') { //
errln("Formatting year 1 as Gannen, got " + aString + " but expected 3rd char to be \u5143");
} else {
// Replace with 1 and parse the result
String bString = aString.replace('\u5143', '1');
try {
Date bDate = fmtWithGannen.parse(bString);
bString = fmtWithGannen.format(bDate);
if (!bString.equals(aString)) {
errln("Parsing 1 when expecting \u5143, formatting the result produced " + bString + " but expected " + aString);
}
} catch (ParseException pe) {
errln("Exception parsing 1 when expecting \u5143 in string " + bString);
}
}
}
@Test

View file

@ -483,9 +483,9 @@ public class DateTimeGeneratorTest extends TestFmwk {
new String[] {"JJmm", "23:58"},
new ULocale("ja@calendar=japanese"), // (new locale for testing ticket 6872<-5702)
new String[] {"yM", "\u5E73\u621011/1"},
new String[] {"yM", "H11/1"},
new String[] {"yMMM", "\u5E73\u621011\u5E741\u6708"},
new String[] {"yMd", "\u5E73\u621011/1/13"},
new String[] {"yMd", "H11/1/13"},
new String[] {"yMMMd", "\u5E73\u621011\u5E741\u670813\u65E5"},
new String[] {"Md", "1/13"},
new String[] {"MMMd", "1\u670813\u65E5"},

View file

@ -139,6 +139,19 @@ public class RbnfRoundTripTest extends TestFmwk {
doTest(formatter, 0, 12345678);
}
/**
* Perform an exhaustive round-trip test on the jpanyear spellout rules
*/
@Test
public void TestJapaneseYearSpelloutRT() {
RuleBasedNumberFormat formatter
= new RuleBasedNumberFormat(Locale.JAPAN,
RuleBasedNumberFormat.SPELLOUT);
formatter.setDefaultRuleSet("%spellout-numbering-year-latn");
doTest(formatter, 0, 50);
}
/**
* Perform an exhaustive round-trip test on the Russian spellout rules
*/

View file

@ -850,6 +850,26 @@ public class RbnfTest extends TestFmwk {
doTest(formatter, testDataYear, true);
}
@Test
public void TestJpanyear()
{
Locale locale = new Locale("ja");
RuleBasedNumberFormat formatter = new RuleBasedNumberFormat(locale,
RuleBasedNumberFormat.SPELLOUT);
String[][] testDataYear = {
{ "0", "0" },
{ "1", "\u5143" }, //
{ "2", "2" },
{ "10", "10" },
{ "31", "31" },
};
formatter.setDefaultRuleSet("%spellout-numbering-year-latn");
logln("testing year rules");
doTest(formatter, testDataYear, true);
}
@Test
public void TestBigNumbers() {
BigInteger bigI = new BigInteger("1234567890", 10);