mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-20536 Japanese era Reiwa support in ICU4C 55
This commit is contained in:
parent
a60b54b55a
commit
f826dc8f93
22 changed files with 76 additions and 17 deletions
|
@ -1420,6 +1420,7 @@ ar{
|
|||
"تيشو",
|
||||
"شووا",
|
||||
"هيسي",
|
||||
"ريوا",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -993,6 +993,7 @@ bs_Cyrl{
|
|||
"Таишо",
|
||||
"Шова",
|
||||
"Хаисеи",
|
||||
"Реива",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1064,6 +1064,7 @@ de{
|
|||
"Taishō",
|
||||
"Shōwa",
|
||||
"Heisei",
|
||||
"Reiwa",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1283,6 +1283,7 @@ he{
|
|||
"Taishō",
|
||||
"Shōwa",
|
||||
"Heisei",
|
||||
"Reiwa",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1085,6 +1085,7 @@ hi{
|
|||
"ताईशो",
|
||||
"शोवा",
|
||||
"हेईसेई",
|
||||
"रेइवा",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1420,6 +1420,7 @@ hr{
|
|||
"Taishō",
|
||||
"Shōwa",
|
||||
"Heisei",
|
||||
"Reiwa",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2262,6 +2262,7 @@ ja{
|
|||
"大正",
|
||||
"昭和",
|
||||
"平成",
|
||||
"令和",
|
||||
}
|
||||
narrow{
|
||||
"大化",
|
||||
|
@ -2500,6 +2501,7 @@ ja{
|
|||
"T",
|
||||
"S",
|
||||
"H",
|
||||
"R",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1621,6 +1621,7 @@ ko{
|
|||
"다이쇼",
|
||||
"쇼와",
|
||||
"헤이세이",
|
||||
"레이와",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1703,6 +1703,7 @@ lo{
|
|||
"ໄຕໂຊ",
|
||||
"ໂຊວາ",
|
||||
"ຮີຊີ",
|
||||
"Reiwa",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2249,6 +2249,7 @@ lt{
|
|||
"Taišo",
|
||||
"Šova",
|
||||
"Heisei",
|
||||
"Reiwa",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1839,6 +1839,7 @@ root{
|
|||
"Taishō",
|
||||
"Shōwa",
|
||||
"Heisei",
|
||||
"Reiwa",
|
||||
}
|
||||
narrow{
|
||||
"Taika (645-650)",
|
||||
|
@ -2077,6 +2078,7 @@ root{
|
|||
"T",
|
||||
"S",
|
||||
"H",
|
||||
"R",
|
||||
}
|
||||
wide:alias{"/LOCALE/calendar/japanese/eras/abbreviated"}
|
||||
}
|
||||
|
|
|
@ -1511,6 +1511,7 @@ ru{
|
|||
"Эпоха Тайсьо",
|
||||
"Сьова",
|
||||
"Эпоха Хэйсэй",
|
||||
"Рэйва",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1102,6 +1102,7 @@ sr{
|
|||
"Таишо",
|
||||
"Шова",
|
||||
"Хаисеи",
|
||||
"Реива",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1103,6 +1103,7 @@ sr_Latn{
|
|||
"Taišo",
|
||||
"Šova",
|
||||
"Haisei",
|
||||
"Reiva",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2192,6 +2192,7 @@ th{
|
|||
"ทะอิโช",
|
||||
"โชวะ",
|
||||
"เฮเซ",
|
||||
"เรวะ",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1941,6 +1941,7 @@ zh{
|
|||
"大正",
|
||||
"昭和",
|
||||
"平成",
|
||||
"令和",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2235,6 +2235,7 @@ zh_Hant{
|
|||
"大正",
|
||||
"昭和",
|
||||
"平成",
|
||||
"令和",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,7 +273,8 @@ static const struct {
|
|||
{ 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]))
|
||||
|
|
|
@ -75,6 +75,7 @@ void IntlCalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &n
|
|||
CASE(7,TestPersian);
|
||||
CASE(8,TestPersianFormat);
|
||||
CASE(9,TestTaiwan);
|
||||
CASE(10,TestJapaneseHeiseiToReiwa);
|
||||
default: name = ""; break;
|
||||
}
|
||||
}
|
||||
|
@ -624,23 +625,23 @@ void IntlCalendarTest::TestJapanese3860()
|
|||
// 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);
|
||||
|
@ -651,7 +652,7 @@ void IntlCalendarTest::TestJapanese3860()
|
|||
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);
|
||||
|
@ -664,7 +665,7 @@ void IntlCalendarTest::TestJapanese3860()
|
|||
// 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);
|
||||
|
@ -676,7 +677,7 @@ void IntlCalendarTest::TestJapanese3860()
|
|||
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");
|
||||
|
@ -689,7 +690,7 @@ void IntlCalendarTest::TestJapanese3860()
|
|||
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 +")");
|
||||
|
@ -698,13 +699,47 @@ void IntlCalendarTest::TestJapanese3860()
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ public:
|
|||
void TestJapanese(void);
|
||||
void TestJapaneseFormat(void);
|
||||
void TestJapanese3860(void);
|
||||
|
||||
void TestJapaneseHeiseiToReiwa(void);
|
||||
|
||||
void TestPersian(void);
|
||||
void TestPersianFormat(void);
|
||||
|
||||
|
|
10
icu4c/source/test/testdata/format.txt
vendored
10
icu4c/source/test/testdata/format.txt
vendored
|
@ -492,35 +492,35 @@ format:table(nofallback) {
|
|||
"",
|
||||
"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"
|
||||
},
|
||||
|
||||
}
|
||||
|
|
3
icu4c/source/test/testdata/structLocale.txt
vendored
3
icu4c/source/test/testdata/structLocale.txt
vendored
|
@ -18047,6 +18047,7 @@ structLocale:table(nofallback){
|
|||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
}
|
||||
wide{
|
||||
"",
|
||||
|
@ -18285,6 +18286,7 @@ structLocale:table(nofallback){
|
|||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
}
|
||||
narrow{
|
||||
"",
|
||||
|
@ -18523,6 +18525,7 @@ structLocale:table(nofallback){
|
|||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue