ICU-20536 Japanese era Reiwa support in ICU4C 52
diff --git a/icu4c/source/data/locales/ar.txt b/icu4c/source/data/locales/ar.txt
index d72d564..929aef4 100644
--- a/icu4c/source/data/locales/ar.txt
+++ b/icu4c/source/data/locales/ar.txt
@@ -1290,6 +1290,7 @@
"تيشو",
"شووا",
"هيسي",
+ "ريوا",
}
}
}
diff --git a/icu4c/source/data/locales/bs_Cyrl.txt b/icu4c/source/data/locales/bs_Cyrl.txt
index 2a3f564..16b20d2 100755
--- a/icu4c/source/data/locales/bs_Cyrl.txt
+++ b/icu4c/source/data/locales/bs_Cyrl.txt
@@ -1023,6 +1023,7 @@
"Таишо",
"Шова",
"Хаисеи",
+ "Реива",
}
}
}
diff --git a/icu4c/source/data/locales/en_HK.txt b/icu4c/source/data/locales/en_HK.txt
index c4de14c..baf7325 100644
--- a/icu4c/source/data/locales/en_HK.txt
+++ b/icu4c/source/data/locales/en_HK.txt
@@ -366,6 +366,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/he.txt b/icu4c/source/data/locales/he.txt
index 6779c7d..030ada8 100644
--- a/icu4c/source/data/locales/he.txt
+++ b/icu4c/source/data/locales/he.txt
@@ -1207,6 +1207,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/hi.txt b/icu4c/source/data/locales/hi.txt
index 49286b4..c00dc9a 100644
--- a/icu4c/source/data/locales/hi.txt
+++ b/icu4c/source/data/locales/hi.txt
@@ -1069,6 +1069,7 @@
"ताईशो",
"शोवा",
"हेईसेई",
+ "रेइवा",
}
}
}
diff --git a/icu4c/source/data/locales/id.txt b/icu4c/source/data/locales/id.txt
index cf9989d..9e17d25 100644
--- a/icu4c/source/data/locales/id.txt
+++ b/icu4c/source/data/locales/id.txt
@@ -1669,6 +1669,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/ja.txt b/icu4c/source/data/locales/ja.txt
index 803b2c2..096f861 100644
--- a/icu4c/source/data/locales/ja.txt
+++ b/icu4c/source/data/locales/ja.txt
@@ -2216,6 +2216,7 @@
"大正",
"昭和",
"平成",
+ "令和",
}
narrow{
"大化",
@@ -2454,6 +2455,7 @@
"T",
"S",
"H",
+ "R",
}
}
}
diff --git a/icu4c/source/data/locales/ko.txt b/icu4c/source/data/locales/ko.txt
index dc1ed81..1e2b0b3 100644
--- a/icu4c/source/data/locales/ko.txt
+++ b/icu4c/source/data/locales/ko.txt
@@ -1360,6 +1360,7 @@
"다이쇼",
"쇼와",
"헤이세이",
+ "레이와",
}
}
}
diff --git a/icu4c/source/data/locales/lo.txt b/icu4c/source/data/locales/lo.txt
index e1a6d8d..d55db10 100755
--- a/icu4c/source/data/locales/lo.txt
+++ b/icu4c/source/data/locales/lo.txt
@@ -1692,6 +1692,7 @@
"ໄຕໂຊ",
"ໂຊວາ",
"ຮີຊີ",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/nl.txt b/icu4c/source/data/locales/nl.txt
index ae1b2ba..f31c81a 100644
--- a/icu4c/source/data/locales/nl.txt
+++ b/icu4c/source/data/locales/nl.txt
@@ -1894,6 +1894,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/root.txt b/icu4c/source/data/locales/root.txt
index 4b78280..6d1ac95 100644
--- a/icu4c/source/data/locales/root.txt
+++ b/icu4c/source/data/locales/root.txt
@@ -1598,6 +1598,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
narrow{
"Taika (645-650)",
@@ -1836,6 +1837,7 @@
"T",
"S",
"H",
+ "R",
}
wide:alias{"/LOCALE/calendar/japanese/eras/abbreviated"}
}
diff --git a/icu4c/source/data/locales/ru.txt b/icu4c/source/data/locales/ru.txt
index 006c92d..a689ab5 100644
--- a/icu4c/source/data/locales/ru.txt
+++ b/icu4c/source/data/locales/ru.txt
@@ -1478,6 +1478,7 @@
"Эпоха Тайсьо",
"Сьова",
"Эпоха Хэйсэй",
+ "Рэйва",
}
}
}
diff --git a/icu4c/source/data/locales/sr.txt b/icu4c/source/data/locales/sr.txt
index 17335d7..b92fbb6 100644
--- a/icu4c/source/data/locales/sr.txt
+++ b/icu4c/source/data/locales/sr.txt
@@ -1095,6 +1095,7 @@
"Таишо",
"Шова",
"Хаисеи",
+ "Реива",
}
}
}
diff --git a/icu4c/source/data/locales/sr_Latn.txt b/icu4c/source/data/locales/sr_Latn.txt
index acbbc3d..9d86ca6 100644
--- a/icu4c/source/data/locales/sr_Latn.txt
+++ b/icu4c/source/data/locales/sr_Latn.txt
@@ -1096,6 +1096,7 @@
"Taišo",
"Šova",
"Haisei",
+ "Reiva",
}
}
}
diff --git a/icu4c/source/data/locales/sv.txt b/icu4c/source/data/locales/sv.txt
index d3ff9b4..08a83c5 100644
--- a/icu4c/source/data/locales/sv.txt
+++ b/icu4c/source/data/locales/sv.txt
@@ -1344,6 +1344,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/th.txt b/icu4c/source/data/locales/th.txt
index 658f0fb..ccb16e0 100644
--- a/icu4c/source/data/locales/th.txt
+++ b/icu4c/source/data/locales/th.txt
@@ -2028,6 +2028,7 @@
"ทะอิโช",
"โชวะ",
"เฮเซ",
+ "เรวะ",
}
}
}
diff --git a/icu4c/source/data/locales/zh.txt b/icu4c/source/data/locales/zh.txt
index ed0e2f4..bb01939 100644
--- a/icu4c/source/data/locales/zh.txt
+++ b/icu4c/source/data/locales/zh.txt
@@ -1904,6 +1904,7 @@
"大正",
"昭和",
"平成",
+ "令和",
}
}
}
diff --git a/icu4c/source/data/locales/zh_Hant.txt b/icu4c/source/data/locales/zh_Hant.txt
index 691e531..16527da 100644
--- a/icu4c/source/data/locales/zh_Hant.txt
+++ b/icu4c/source/data/locales/zh_Hant.txt
@@ -2155,6 +2155,7 @@
"大正",
"昭和",
"平成",
+ "令和",
}
}
}
diff --git a/icu4c/source/i18n/japancal.cpp b/icu4c/source/i18n/japancal.cpp
index 0f985f0..7886185 100644
--- a/icu4c/source/i18n/japancal.cpp
+++ b/icu4c/source/i18n/japancal.cpp
@@ -273,7 +273,8 @@
{ 1868, 9, 8 }, // Meiji 232
{ 1912, 7, 30 }, // Taisho 233
{ 1926, 12, 25 }, // Showa 234
- { 1989, 1, 8 } // Heisei 235
+ { 1989, 1, 8 }, // Heisei 235
+ { 2019, 5, 1 } // Reiwa 236
};
#define kEraCount (sizeof(kEraInfo)/sizeof(kEraInfo[0]))
diff --git a/icu4c/source/test/intltest/incaltst.cpp b/icu4c/source/test/intltest/incaltst.cpp
index 9614035..d21160b 100644
--- a/icu4c/source/test/intltest/incaltst.cpp
+++ b/icu4c/source/test/intltest/incaltst.cpp
@@ -78,6 +78,7 @@
CASE(7,TestPersian);
CASE(8,TestPersianFormat);
CASE(9,TestTaiwan);
+ CASE(10,TestJapaneseHeiseiToReiwa);
default: name = ""; break;
}
}
@@ -627,23 +628,23 @@
// Test simple parse/format with adopt
UDate aDate = 0;
- // Test parse with missing era (should default to current era, heisei)
+ // Test parse with missing era (should default to current era)
// Test parse with incomplete information
logln("Testing parse w/ missing era...");
- SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("y.M.d"), Locale("ja_JP@calendar=japanese"), status);
+ SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("y/M/d"), Locale("ja_JP@calendar=japanese"), status);
CHECK(status, "creating date format instance");
if(!fmt) {
errln("Coudln't create en_US instance");
} else {
UErrorCode s2 = U_ZERO_ERROR;
cal2->clear();
- UnicodeString samplestr("1.1.9");
+ UnicodeString samplestr("1/5/9");
logln(UnicodeString() + "Test Year: " + samplestr);
aDate = fmt->parse(samplestr, s2);
ParsePosition pp=0;
fmt->parse(samplestr, *cal2, pp);
- CHECK(s2, "parsing the 1.1.9 string");
- logln("*cal2 after 119 parse:");
+ CHECK(s2, "parsing the 1/5/9 string");
+ logln("*cal2 after 159 parse:");
str.remove();
fmt2->format(aDate, str);
logln(UnicodeString() + "as Gregorian Calendar: " + str);
@@ -654,7 +655,7 @@
int32_t expectYear = 1;
int32_t expectEra = JapaneseCalendar::getCurrentEra();
if((gotYear!=1) || (gotEra != expectEra)) {
- errln(UnicodeString("parse "+samplestr+" of 'y.m.d' as Japanese Calendar, expected year ") + expectYear +
+ errln(UnicodeString("parse "+samplestr+" of 'y/m/d' as Japanese Calendar, expected year ") + expectYear +
UnicodeString(" and era ") + expectEra +", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")");
} else {
logln(UnicodeString() + " year: " + gotYear + ", era: " + gotEra);
@@ -667,7 +668,7 @@
// Test simple parse/format with adopt
UDate aDate = 0;
- // Test parse with missing era (should default to current era, heisei)
+ // Test parse with missing era (should default to current era)
// Test parse with incomplete information
logln("Testing parse w/ just year...");
SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("y"), Locale("ja_JP@calendar=japanese"), status);
@@ -679,7 +680,7 @@
cal2->clear();
UnicodeString samplestr("1");
logln(UnicodeString() + "Test Year: " + samplestr);
- aDate = fmt->parse(samplestr, s2);
+ aDate = fmt->parse(samplestr, s2); // Should be parsed as the first day of the current era
ParsePosition pp=0;
fmt->parse(samplestr, *cal2, pp);
CHECK(s2, "parsing the 1 string");
@@ -692,7 +693,7 @@
int32_t gotYear = cal2->get(UCAL_YEAR, s2);
int32_t gotEra = cal2->get(UCAL_ERA, s2);
int32_t expectYear = 1;
- int32_t expectEra = 235; //JapaneseCalendar::kCurrentEra;
+ int32_t expectEra = JapaneseCalendar::getCurrentEra();
if((gotYear!=1) || (gotEra != expectEra)) {
errln(UnicodeString("parse "+samplestr+" of 'y' as Japanese Calendar, expected year ") + expectYear +
UnicodeString(" and era ") + expectEra +", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")");
@@ -701,13 +702,47 @@
}
delete fmt;
}
- }
+ }
delete cal2;
delete cal;
delete fmt2;
}
+void IntlCalendarTest::TestJapaneseHeiseiToReiwa() {
+ Calendar *cal;
+ UErrorCode status = U_ZERO_ERROR;
+ cal = Calendar::createInstance(status);
+ CHECK(status, UnicodeString("Creating default Gregorian Calendar"));
+ cal->set(2019, UCAL_APRIL, 29);
+
+ DateFormat *jfmt = DateFormat::createDateInstance(DateFormat::LONG, "ja@calendar=japanese");
+ CHECK(status, UnicodeString("Creating date format ja@calendar=japanese"))
+
+ const char* EXPECTED_FORMAT[4] = {
+ "\\u5E73\\u621031\\u5E744\\u670829\\u65E5", // Heisei 31 April 29
+ "\\u5E73\\u621031\\u5E744\\u670830\\u65E5", // Heisei 31 April 30
+ "\\u4EE4\\u548c1\\u5E745\\u67081\\u65E5", // Reiwa 1 May 1
+ "\\u4EE4\\u548c1\\u5E745\\u67082\\u65E5" // Reiwa 1 May 2
+ };
+
+ for (int32_t i = 0; i < 4; i++) {
+ UnicodeString dateStr;
+ UDate d = cal->getTime(status);
+ CHECK(status, UnicodeString("Get test date"));
+ jfmt->format(d, dateStr);
+ UnicodeString expected(UnicodeString(EXPECTED_FORMAT[i], -1, US_INV).unescape());
+ if (expected.compare(dateStr) != 0) {
+ errln(UnicodeString("Formatting year:") + cal->get(UCAL_YEAR, status) + " month:"
+ + cal->get(UCAL_MONTH, status) + " day:" + (cal->get(UCAL_DATE, status) + 1)
+ + " - expected: " + expected + " / actual: " + dateStr);
+ }
+ cal->add(UCAL_DATE, 1, status);
+ CHECK(status, UnicodeString("Add 1 day"));
+ }
+ delete jfmt;
+ delete cal;
+}
diff --git a/icu4c/source/test/intltest/incaltst.h b/icu4c/source/test/intltest/incaltst.h
index 2c03ce3..45d6727 100644
--- a/icu4c/source/test/intltest/incaltst.h
+++ b/icu4c/source/test/intltest/incaltst.h
@@ -32,7 +32,8 @@
void TestJapanese(void);
void TestJapaneseFormat(void);
void TestJapanese3860(void);
-
+ void TestJapaneseHeiseiToReiwa(void);
+
void TestPersian(void);
void TestPersianFormat(void);
diff --git a/icu4c/source/test/testdata/format.txt b/icu4c/source/test/testdata/format.txt
index e999cfd..31b78b4 100644
--- a/icu4c/source/test/testdata/format.txt
+++ b/icu4c/source/test/testdata/format.txt
@@ -492,35 +492,35 @@
"",
"PATTERN=G y",
"YEAR=8",
- "Heisei 8"
+ "Reiwa 8"
},
{
"en_US@calendar=japanese",
"",
"PATTERN=G yy",
"YEAR=8",
- "Heisei 08"
+ "Reiwa 08"
},
{
"en_US@calendar=japanese",
"",
"PATTERN=G yyy",
"YEAR=8",
- "Heisei 008"
+ "Reiwa 008"
},
{
"en_US@calendar=japanese",
"",
"PATTERN=G yyyy",
"YEAR=8",
- "Heisei 0008"
+ "Reiwa 0008"
},
{
"en_US@calendar=japanese",
"",
"PATTERN=G yyyyy",
"YEAR=8",
- "Heisei 00008"
+ "Reiwa 00008"
},
}
diff --git a/icu4c/source/test/testdata/structLocale.txt b/icu4c/source/test/testdata/structLocale.txt
index 50c572d..75d5501 100644
--- a/icu4c/source/test/testdata/structLocale.txt
+++ b/icu4c/source/test/testdata/structLocale.txt
@@ -16607,6 +16607,7 @@
"",
"",
"",
+ "",
}
wide{
"",
@@ -17083,6 +17084,7 @@
"",
"",
"",
+ "",
}
}
}