ICU-20536 Japanese era Reiwa support in ICU4C 50
diff --git a/icu4c/source/data/locales/ar.txt b/icu4c/source/data/locales/ar.txt
index 406db0f..6a450f3 100644
--- a/icu4c/source/data/locales/ar.txt
+++ b/icu4c/source/data/locales/ar.txt
@@ -1217,6 +1217,7 @@
"تيشو",
"شووا",
"هيسي",
+ "ريوا",
}
}
}
diff --git a/icu4c/source/data/locales/bs_Cyrl.txt b/icu4c/source/data/locales/bs_Cyrl.txt
index 3432aed..a2cb715 100755
--- a/icu4c/source/data/locales/bs_Cyrl.txt
+++ b/icu4c/source/data/locales/bs_Cyrl.txt
@@ -930,6 +930,7 @@
"Таишо",
"Шова",
"Хаисеи",
+ "Реива",
}
}
}
diff --git a/icu4c/source/data/locales/en_HK.txt b/icu4c/source/data/locales/en_HK.txt
index dd89b2c..31bd7f4 100644
--- a/icu4c/source/data/locales/en_HK.txt
+++ b/icu4c/source/data/locales/en_HK.txt
@@ -374,6 +374,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/he.txt b/icu4c/source/data/locales/he.txt
index 0e981d4..e454869 100644
--- a/icu4c/source/data/locales/he.txt
+++ b/icu4c/source/data/locales/he.txt
@@ -1061,6 +1061,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/hi.txt b/icu4c/source/data/locales/hi.txt
index 9ef83e8..bcb73a3 100644
--- a/icu4c/source/data/locales/hi.txt
+++ b/icu4c/source/data/locales/hi.txt
@@ -777,6 +777,7 @@
"ताईशो",
"शोवा",
"हेईसेई",
+ "रेइवा",
}
}
}
diff --git a/icu4c/source/data/locales/id.txt b/icu4c/source/data/locales/id.txt
index 3450774..8d1d48f 100644
--- a/icu4c/source/data/locales/id.txt
+++ b/icu4c/source/data/locales/id.txt
@@ -1599,6 +1599,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/ja.txt b/icu4c/source/data/locales/ja.txt
index e48b88a..fb3e9f0 100644
--- a/icu4c/source/data/locales/ja.txt
+++ b/icu4c/source/data/locales/ja.txt
@@ -1693,6 +1693,7 @@
"大正",
"昭和",
"平成",
+ "令和",
}
narrow{
"大化",
@@ -1931,6 +1932,7 @@
"大",
"昭",
"平",
+ "令",
}
}
}
diff --git a/icu4c/source/data/locales/ko.txt b/icu4c/source/data/locales/ko.txt
index 7344e2b..684c1f4 100644
--- a/icu4c/source/data/locales/ko.txt
+++ b/icu4c/source/data/locales/ko.txt
@@ -950,6 +950,7 @@
"다이쇼",
"쇼와",
"헤이세이",
+ "레이와",
}
}
}
diff --git a/icu4c/source/data/locales/lo.txt b/icu4c/source/data/locales/lo.txt
index fc1b549..21a2e55 100755
--- a/icu4c/source/data/locales/lo.txt
+++ b/icu4c/source/data/locales/lo.txt
@@ -1583,6 +1583,7 @@
"ໄຕໂຊ",
"ໂຊວາ",
"ຮີຊີ",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/root.txt b/icu4c/source/data/locales/root.txt
index 542f554..0984c68 100644
--- a/icu4c/source/data/locales/root.txt
+++ b/icu4c/source/data/locales/root.txt
@@ -1434,6 +1434,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
narrow{
"Taika (645-650)",
@@ -1672,6 +1673,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 282f79e..13dce05 100644
--- a/icu4c/source/data/locales/ru.txt
+++ b/icu4c/source/data/locales/ru.txt
@@ -1468,6 +1468,7 @@
"Эпоха Тайсьо",
"Сьова",
"Эпоха Хэйсэй",
+ "Рэйва",
}
}
}
diff --git a/icu4c/source/data/locales/sr.txt b/icu4c/source/data/locales/sr.txt
index 68c0339..b99b381 100644
--- a/icu4c/source/data/locales/sr.txt
+++ b/icu4c/source/data/locales/sr.txt
@@ -1004,6 +1004,7 @@
"Таишо",
"Шова",
"Хаисеи",
+ "Реива",
}
}
}
diff --git a/icu4c/source/data/locales/sv.txt b/icu4c/source/data/locales/sv.txt
index 6be3d45..c43b642 100644
--- a/icu4c/source/data/locales/sv.txt
+++ b/icu4c/source/data/locales/sv.txt
@@ -1289,6 +1289,7 @@
"Taishō",
"Shōwa",
"Heisei",
+ "Reiwa",
}
}
}
diff --git a/icu4c/source/data/locales/th.txt b/icu4c/source/data/locales/th.txt
index 54239c7..82a04fb 100644
--- a/icu4c/source/data/locales/th.txt
+++ b/icu4c/source/data/locales/th.txt
@@ -1712,6 +1712,7 @@
"ทะอิโช",
"โชวะ",
"เฮเซ",
+ "เรวะ",
}
}
}
diff --git a/icu4c/source/data/locales/zh.txt b/icu4c/source/data/locales/zh.txt
index e4c6ded..c69b9a9 100644
--- a/icu4c/source/data/locales/zh.txt
+++ b/icu4c/source/data/locales/zh.txt
@@ -1804,6 +1804,7 @@
"大正",
"昭和",
"平成",
+ "令和",
}
}
}
diff --git a/icu4c/source/data/locales/zh_Hant.txt b/icu4c/source/data/locales/zh_Hant.txt
index a84b4d7..3497160 100644
--- a/icu4c/source/data/locales/zh_Hant.txt
+++ b/icu4c/source/data/locales/zh_Hant.txt
@@ -1692,6 +1692,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/i18n/uspoof.cpp b/icu4c/source/i18n/uspoof.cpp
index a898432..43c387a 100644
--- a/icu4c/source/i18n/uspoof.cpp
+++ b/icu4c/source/i18n/uspoof.cpp
@@ -369,7 +369,7 @@
// u_strToUTF8() in preflight mode is an easy way to do it.
U_ASSERT(position16 <= len16);
u_strToUTF8(NULL, 0, position, text16, position16, status);
- if (position > 0) {
+ if (*position > 0) {
// position is the required buffer length from u_strToUTF8, which includes
// space for a terminating NULL, which we don't want, hence the -1.
*position -= 1;
diff --git a/icu4c/source/test/intltest/dtfmttst.cpp b/icu4c/source/test/intltest/dtfmttst.cpp
index 47a289e..399a58d 100644
--- a/icu4c/source/test/intltest/dtfmttst.cpp
+++ b/icu4c/source/test/intltest/dtfmttst.cpp
@@ -1116,8 +1116,8 @@
dataerrln("FAIL: SimpleDateFormat constructor - %s", u_errorName(ec));
return;
}
- parse2DigitYear(fmt, "5/6/17", date(117, UCAL_JUNE, 5));
- parse2DigitYear(fmt, "4/6/34", date(34, UCAL_JUNE, 4));
+ parse2DigitYear(fmt, "5/6/30", date(130, UCAL_JUNE, 5));
+ parse2DigitYear(fmt, "4/6/50", date(50, UCAL_JUNE, 4));
}
// -------------------------------------
diff --git a/icu4c/source/test/intltest/incaltst.cpp b/icu4c/source/test/intltest/incaltst.cpp
index 9614035..3488cea 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 9827bd6..bc5f356 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 a1d3be5..67317fc 100644
--- a/icu4c/source/test/testdata/structLocale.txt
+++ b/icu4c/source/test/testdata/structLocale.txt
@@ -15428,6 +15428,7 @@
"",
"",
"",
+ "",
}
wide{
"",
@@ -15666,6 +15667,7 @@
"",
"",
"",
+ "",
}
narrow{
"",
@@ -15904,6 +15906,7 @@
"",
"",
"",
+ "",
}
}
}