michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2003-2009,2012, International Business Machines Corporation and * michael@0: * others. All Rights Reserved. * michael@0: ******************************************************************************* michael@0: * michael@0: * File JAPANCAL.CPP michael@0: * michael@0: * Modification History: michael@0: * 05/16/2003 srl copied from buddhcal.cpp michael@0: * michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "japancal.h" michael@0: #include "unicode/gregocal.h" michael@0: #include "umutex.h" michael@0: #include "uassert.h" michael@0: michael@0: //#define U_DEBUG_JCAL michael@0: michael@0: #ifdef U_DEBUG_JCAL michael@0: #include michael@0: #endif michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(JapaneseCalendar) michael@0: michael@0: // Gregorian date of each emperor's ascension michael@0: // Years are AD, months are 1-based. michael@0: static const struct { michael@0: int16_t year; michael@0: int8_t month; michael@0: int8_t day; michael@0: } kEraInfo[] = { michael@0: // Year Month Day michael@0: { 645, 6, 19 }, // Taika 0 michael@0: { 650, 2, 15 }, // Hakuchi 1 michael@0: { 672, 1, 1 }, // Hakuho 2 michael@0: { 686, 7, 20 }, // Shucho 3 michael@0: { 701, 3, 21 }, // Taiho 4 michael@0: { 704, 5, 10 }, // Keiun 5 michael@0: { 708, 1, 11 }, // Wado 6 michael@0: { 715, 9, 2 }, // Reiki 7 michael@0: { 717, 11, 17 }, // Yoro 8 michael@0: { 724, 2, 4 }, // Jinki 9 michael@0: { 729, 8, 5 }, // Tempyo 10 michael@0: { 749, 4, 14 }, // Tempyo-kampo 11 michael@0: { 749, 7, 2 }, // Tempyo-shoho 12 michael@0: { 757, 8, 18 }, // Tempyo-hoji 13 michael@0: { 765, 1, 7 }, // Tempho-jingo 14 michael@0: { 767, 8, 16 }, // Jingo-keiun 15 michael@0: { 770, 10, 1 }, // Hoki 16 michael@0: { 781, 1, 1 }, // Ten-o 17 michael@0: { 782, 8, 19 }, // Enryaku 18 michael@0: { 806, 5, 18 }, // Daido 19 michael@0: { 810, 9, 19 }, // Konin 20 michael@0: { 824, 1, 5 }, // Tencho michael@0: { 834, 1, 3 }, // Showa michael@0: { 848, 6, 13 }, // Kajo michael@0: { 851, 4, 28 }, // Ninju michael@0: { 854, 11, 30 }, // Saiko michael@0: { 857, 2, 21 }, // Tennan michael@0: { 859, 4, 15 }, // Jogan michael@0: { 877, 4, 16 }, // Genkei michael@0: { 885, 2, 21 }, // Ninna michael@0: { 889, 4, 27 }, // Kampyo 30 michael@0: { 898, 4, 26 }, // Shotai michael@0: { 901, 7, 15 }, // Engi michael@0: { 923, 4, 11 }, // Encho michael@0: { 931, 4, 26 }, // Shohei michael@0: { 938, 5, 22 }, // Tengyo michael@0: { 947, 4, 22 }, // Tenryaku michael@0: { 957, 10, 27 }, // Tentoku michael@0: { 961, 2, 16 }, // Owa michael@0: { 964, 7, 10 }, // Koho michael@0: { 968, 8, 13 }, // Anna 40 michael@0: { 970, 3, 25 }, // Tenroku michael@0: { 973, 12, 20 }, // Ten-en michael@0: { 976, 7, 13 }, // Jogen michael@0: { 978, 11, 29 }, // Tengen michael@0: { 983, 4, 15 }, // Eikan michael@0: { 985, 4, 27 }, // Kanna michael@0: { 987, 4, 5 }, // Ei-en michael@0: { 989, 8, 8 }, // Eiso michael@0: { 990, 11, 7 }, // Shoryaku michael@0: { 995, 2, 22 }, // Chotoku 50 michael@0: { 999, 1, 13 }, // Choho michael@0: { 1004, 7, 20 }, // Kanko michael@0: { 1012, 12, 25 }, // Chowa michael@0: { 1017, 4, 23 }, // Kannin michael@0: { 1021, 2, 2 }, // Jian michael@0: { 1024, 7, 13 }, // Manju michael@0: { 1028, 7, 25 }, // Chogen michael@0: { 1037, 4, 21 }, // Choryaku michael@0: { 1040, 11, 10 }, // Chokyu michael@0: { 1044, 11, 24 }, // Kantoku 60 michael@0: { 1046, 4, 14 }, // Eisho michael@0: { 1053, 1, 11 }, // Tengi michael@0: { 1058, 8, 29 }, // Kohei michael@0: { 1065, 8, 2 }, // Jiryaku michael@0: { 1069, 4, 13 }, // Enkyu michael@0: { 1074, 8, 23 }, // Shoho michael@0: { 1077, 11, 17 }, // Shoryaku michael@0: { 1081, 2, 10 }, // Eiho michael@0: { 1084, 2, 7 }, // Otoku michael@0: { 1087, 4, 7 }, // Kanji 70 michael@0: { 1094, 12, 15 }, // Kaho michael@0: { 1096, 12, 17 }, // Eicho michael@0: { 1097, 11, 21 }, // Shotoku michael@0: { 1099, 8, 28 }, // Kowa michael@0: { 1104, 2, 10 }, // Choji michael@0: { 1106, 4, 9 }, // Kasho michael@0: { 1108, 8, 3 }, // Tennin michael@0: { 1110, 7, 13 }, // Ten-ei michael@0: { 1113, 7, 13 }, // Eikyu michael@0: { 1118, 4, 3 }, // Gen-ei 80 michael@0: { 1120, 4, 10 }, // Hoan michael@0: { 1124, 4, 3 }, // Tenji michael@0: { 1126, 1, 22 }, // Daiji michael@0: { 1131, 1, 29 }, // Tensho michael@0: { 1132, 8, 11 }, // Chosho michael@0: { 1135, 4, 27 }, // Hoen michael@0: { 1141, 7, 10 }, // Eiji michael@0: { 1142, 4, 28 }, // Koji michael@0: { 1144, 2, 23 }, // Tenyo michael@0: { 1145, 7, 22 }, // Kyuan 90 michael@0: { 1151, 1, 26 }, // Ninpei michael@0: { 1154, 10, 28 }, // Kyuju michael@0: { 1156, 4, 27 }, // Hogen michael@0: { 1159, 4, 20 }, // Heiji michael@0: { 1160, 1, 10 }, // Eiryaku michael@0: { 1161, 9, 4 }, // Oho michael@0: { 1163, 3, 29 }, // Chokan michael@0: { 1165, 6, 5 }, // Eiman michael@0: { 1166, 8, 27 }, // Nin-an michael@0: { 1169, 4, 8 }, // Kao 100 michael@0: { 1171, 4, 21 }, // Shoan michael@0: { 1175, 7, 28 }, // Angen michael@0: { 1177, 8, 4 }, // Jisho michael@0: { 1181, 7, 14 }, // Yowa michael@0: { 1182, 5, 27 }, // Juei michael@0: { 1184, 4, 16 }, // Genryuku michael@0: { 1185, 8, 14 }, // Bunji michael@0: { 1190, 4, 11 }, // Kenkyu michael@0: { 1199, 4, 27 }, // Shoji michael@0: { 1201, 2, 13 }, // Kennin 110 michael@0: { 1204, 2, 20 }, // Genkyu michael@0: { 1206, 4, 27 }, // Ken-ei michael@0: { 1207, 10, 25 }, // Shogen michael@0: { 1211, 3, 9 }, // Kenryaku michael@0: { 1213, 12, 6 }, // Kenpo michael@0: { 1219, 4, 12 }, // Shokyu michael@0: { 1222, 4, 13 }, // Joo michael@0: { 1224, 11, 20 }, // Gennin michael@0: { 1225, 4, 20 }, // Karoku michael@0: { 1227, 12, 10 }, // Antei 120 michael@0: { 1229, 3, 5 }, // Kanki michael@0: { 1232, 4, 2 }, // Joei michael@0: { 1233, 4, 15 }, // Tempuku michael@0: { 1234, 11, 5 }, // Bunryaku michael@0: { 1235, 9, 19 }, // Katei michael@0: { 1238, 11, 23 }, // Ryakunin michael@0: { 1239, 2, 7 }, // En-o michael@0: { 1240, 7, 16 }, // Ninji michael@0: { 1243, 2, 26 }, // Kangen michael@0: { 1247, 2, 28 }, // Hoji 130 michael@0: { 1249, 3, 18 }, // Kencho michael@0: { 1256, 10, 5 }, // Kogen michael@0: { 1257, 3, 14 }, // Shoka michael@0: { 1259, 3, 26 }, // Shogen michael@0: { 1260, 4, 13 }, // Bun-o michael@0: { 1261, 2, 20 }, // Kocho michael@0: { 1264, 2, 28 }, // Bun-ei michael@0: { 1275, 4, 25 }, // Kenji michael@0: { 1278, 2, 29 }, // Koan michael@0: { 1288, 4, 28 }, // Shoo 140 michael@0: { 1293, 8, 55 }, // Einin michael@0: { 1299, 4, 25 }, // Shoan michael@0: { 1302, 11, 21 }, // Kengen michael@0: { 1303, 8, 5 }, // Kagen michael@0: { 1306, 12, 14 }, // Tokuji michael@0: { 1308, 10, 9 }, // Enkei michael@0: { 1311, 4, 28 }, // Ocho michael@0: { 1312, 3, 20 }, // Showa michael@0: { 1317, 2, 3 }, // Bunpo michael@0: { 1319, 4, 28 }, // Geno 150 michael@0: { 1321, 2, 23 }, // Genkyo michael@0: { 1324, 12, 9 }, // Shochu michael@0: { 1326, 4, 26 }, // Kareki michael@0: { 1329, 8, 29 }, // Gentoku michael@0: { 1331, 8, 9 }, // Genko michael@0: { 1334, 1, 29 }, // Kemmu michael@0: { 1336, 2, 29 }, // Engen michael@0: { 1340, 4, 28 }, // Kokoku michael@0: { 1346, 12, 8 }, // Shohei michael@0: { 1370, 7, 24 }, // Kentoku 160 michael@0: { 1372, 4, 1 }, // Bunch\u0169 michael@0: { 1375, 5, 27 }, // Tenju michael@0: { 1379, 3, 22 }, // Koryaku michael@0: { 1381, 2, 10 }, // Kowa michael@0: { 1384, 4, 28 }, // Gench\u0169 michael@0: { 1384, 2, 27 }, // Meitoku michael@0: { 1387, 8, 23 }, // Kakei michael@0: { 1389, 2, 9 }, // Koo michael@0: { 1390, 3, 26 }, // Meitoku michael@0: { 1394, 7, 5 }, // Oei 170 michael@0: { 1428, 4, 27 }, // Shocho michael@0: { 1429, 9, 5 }, // Eikyo michael@0: { 1441, 2, 17 }, // Kakitsu michael@0: { 1444, 2, 5 }, // Bun-an michael@0: { 1449, 7, 28 }, // Hotoku michael@0: { 1452, 7, 25 }, // Kyotoku michael@0: { 1455, 7, 25 }, // Kosho michael@0: { 1457, 9, 28 }, // Choroku michael@0: { 1460, 12, 21 }, // Kansho michael@0: { 1466, 2, 28 }, // Bunsho 180 michael@0: { 1467, 3, 3 }, // Onin michael@0: { 1469, 4, 28 }, // Bunmei michael@0: { 1487, 7, 29 }, // Chokyo michael@0: { 1489, 8, 21 }, // Entoku michael@0: { 1492, 7, 19 }, // Meio michael@0: { 1501, 2, 29 }, // Bunki michael@0: { 1504, 2, 30 }, // Eisho michael@0: { 1521, 8, 23 }, // Taiei michael@0: { 1528, 8, 20 }, // Kyoroku michael@0: { 1532, 7, 29 }, // Tenmon 190 michael@0: { 1555, 10, 23 }, // Koji michael@0: { 1558, 2, 28 }, // Eiroku michael@0: { 1570, 4, 23 }, // Genki michael@0: { 1573, 7, 28 }, // Tensho michael@0: { 1592, 12, 8 }, // Bunroku michael@0: { 1596, 10, 27 }, // Keicho michael@0: { 1615, 7, 13 }, // Genwa michael@0: { 1624, 2, 30 }, // Kan-ei michael@0: { 1644, 12, 16 }, // Shoho michael@0: { 1648, 2, 15 }, // Keian 200 michael@0: { 1652, 9, 18 }, // Shoo michael@0: { 1655, 4, 13 }, // Meiryaku michael@0: { 1658, 7, 23 }, // Manji michael@0: { 1661, 4, 25 }, // Kanbun michael@0: { 1673, 9, 21 }, // Enpo michael@0: { 1681, 9, 29 }, // Tenwa michael@0: { 1684, 2, 21 }, // Jokyo michael@0: { 1688, 9, 30 }, // Genroku michael@0: { 1704, 3, 13 }, // Hoei michael@0: { 1711, 4, 25 }, // Shotoku 210 michael@0: { 1716, 6, 22 }, // Kyoho michael@0: { 1736, 4, 28 }, // Genbun michael@0: { 1741, 2, 27 }, // Kanpo michael@0: { 1744, 2, 21 }, // Enkyo michael@0: { 1748, 7, 12 }, // Kan-en michael@0: { 1751, 10, 27 }, // Horyaku michael@0: { 1764, 6, 2 }, // Meiwa michael@0: { 1772, 11, 16 }, // An-ei michael@0: { 1781, 4, 2 }, // Tenmei michael@0: { 1789, 1, 25 }, // Kansei 220 michael@0: { 1801, 2, 5 }, // Kyowa michael@0: { 1804, 2, 11 }, // Bunka michael@0: { 1818, 4, 22 }, // Bunsei michael@0: { 1830, 12, 10 }, // Tenpo michael@0: { 1844, 12, 2 }, // Koka michael@0: { 1848, 2, 28 }, // Kaei michael@0: { 1854, 11, 27 }, // Ansei michael@0: { 1860, 3, 18 }, // Man-en michael@0: { 1861, 2, 19 }, // Bunkyu michael@0: { 1864, 2, 20 }, // Genji 230 michael@0: { 1865, 4, 7 }, // Keio 231 michael@0: { 1868, 9, 8 }, // Meiji 232 michael@0: { 1912, 7, 30 }, // Taisho 233 michael@0: { 1926, 12, 25 }, // Showa 234 michael@0: { 1989, 1, 8 } // Heisei 235 michael@0: }; michael@0: michael@0: #define kEraCount (sizeof(kEraInfo)/sizeof(kEraInfo[0])) michael@0: michael@0: /** michael@0: * The current era, for reference. michael@0: */ michael@0: static const int32_t kCurrentEra = (kEraCount-1); // int32_t to match the calendar field type michael@0: michael@0: static const int32_t kGregorianEpoch = 1970; // used as the default value of EXTENDED_YEAR michael@0: michael@0: /* Some platforms don't like to export constants, like old Palm OS and some z/OS configurations. */ michael@0: uint32_t JapaneseCalendar::getCurrentEra() { michael@0: return kCurrentEra; michael@0: } michael@0: michael@0: JapaneseCalendar::JapaneseCalendar(const Locale& aLocale, UErrorCode& success) michael@0: : GregorianCalendar(aLocale, success) michael@0: { michael@0: setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly. michael@0: } michael@0: michael@0: JapaneseCalendar::~JapaneseCalendar() michael@0: { michael@0: } michael@0: michael@0: JapaneseCalendar::JapaneseCalendar(const JapaneseCalendar& source) michael@0: : GregorianCalendar(source) michael@0: { michael@0: } michael@0: michael@0: JapaneseCalendar& JapaneseCalendar::operator= ( const JapaneseCalendar& right) michael@0: { michael@0: GregorianCalendar::operator=(right); michael@0: return *this; michael@0: } michael@0: michael@0: Calendar* JapaneseCalendar::clone(void) const michael@0: { michael@0: return new JapaneseCalendar(*this); michael@0: } michael@0: michael@0: const char *JapaneseCalendar::getType() const michael@0: { michael@0: return "japanese"; michael@0: } michael@0: michael@0: int32_t JapaneseCalendar::getDefaultMonthInYear(int32_t eyear) michael@0: { michael@0: int32_t era = internalGetEra(); michael@0: // TODO do we assume we can trust 'era'? What if it is denormalized? michael@0: michael@0: int32_t month = 0; michael@0: michael@0: // Find out if we are at the edge of an era michael@0: michael@0: if(eyear == kEraInfo[era].year) { michael@0: // Yes, we're in the first year of this era. michael@0: return kEraInfo[era].month-1; michael@0: } michael@0: michael@0: return month; michael@0: } michael@0: michael@0: int32_t JapaneseCalendar::getDefaultDayInMonth(int32_t eyear, int32_t month) michael@0: { michael@0: int32_t era = internalGetEra(); michael@0: int32_t day = 1; michael@0: michael@0: if(eyear == kEraInfo[era].year) { michael@0: if(month == (kEraInfo[era].month-1)) { michael@0: return kEraInfo[era].day; michael@0: } michael@0: } michael@0: michael@0: return day; michael@0: } michael@0: michael@0: michael@0: int32_t JapaneseCalendar::internalGetEra() const michael@0: { michael@0: return internalGet(UCAL_ERA, kCurrentEra); michael@0: } michael@0: michael@0: int32_t JapaneseCalendar::handleGetExtendedYear() michael@0: { michael@0: // EXTENDED_YEAR in JapaneseCalendar is a Gregorian year michael@0: // The default value of EXTENDED_YEAR is 1970 (Showa 45) michael@0: int32_t year; michael@0: michael@0: if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR && michael@0: newerField(UCAL_EXTENDED_YEAR, UCAL_ERA) == UCAL_EXTENDED_YEAR) { michael@0: year = internalGet(UCAL_EXTENDED_YEAR, kGregorianEpoch); michael@0: } else { michael@0: // Subtract one because year starts at 1 michael@0: year = internalGet(UCAL_YEAR) + kEraInfo[internalGetEra()].year - 1; michael@0: } michael@0: return year; michael@0: } michael@0: michael@0: michael@0: void JapaneseCalendar::handleComputeFields(int32_t julianDay, UErrorCode& status) michael@0: { michael@0: //Calendar::timeToFields(theTime, quick, status); michael@0: GregorianCalendar::handleComputeFields(julianDay, status); michael@0: int32_t year = internalGet(UCAL_EXTENDED_YEAR); // Gregorian year michael@0: michael@0: int32_t low = 0; michael@0: michael@0: // Short circuit for recent years. Most modern computations will michael@0: // occur in the current era and won't require the binary search. michael@0: // Note that if the year is == the current era year, then we use michael@0: // the binary search to handle the month/dom comparison. michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, "== %d \n", year); michael@0: #endif michael@0: michael@0: if (year > kEraInfo[kCurrentEra].year) { michael@0: low = kCurrentEra; michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, " low=%d (special)\n", low); michael@0: #endif michael@0: } else { michael@0: // Binary search michael@0: int32_t high = kEraCount; michael@0: michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, " high=%d\n", high); michael@0: #endif michael@0: while (low < high - 1) { michael@0: int32_t i = (low + high) / 2; michael@0: int32_t diff = year - kEraInfo[i].year; michael@0: michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, " d=%d low=%d, high=%d. Considering %d:M%d D%d Y%d. { we are ?:M%d D%d Y%d }\n", michael@0: diff,low, high, i, kEraInfo[i].month-1, kEraInfo[i].day, kEraInfo[i].year, internalGet(UCAL_MONTH), internalGet(UCAL_DATE),year); michael@0: #endif michael@0: michael@0: // If years are the same, then compare the months, and if those michael@0: // are the same, compare days of month. In the ERAS array michael@0: // months are 1-based for easier maintenance. michael@0: if (diff == 0) { michael@0: diff = internalGet(UCAL_MONTH) - (kEraInfo[i].month - 1); michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, "diff now %d (M) = %d - %d - 1\n", diff, internalGet(UCAL_MONTH), kEraInfo[i].month); michael@0: #endif michael@0: if (diff == 0) { michael@0: diff = internalGet(UCAL_DATE) - kEraInfo[i].day; michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, "diff now %d (D)\n", diff); michael@0: #endif michael@0: } michael@0: } michael@0: if (diff >= 0) { michael@0: low = i; michael@0: } else { michael@0: high = i; michael@0: } michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, ". low=%d, high=%d, i=%d, diff=%d.. %d\n", low, high, i, diff, year); michael@0: #endif michael@0: michael@0: } michael@0: } michael@0: michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, " low[era]=%d,.. %d\n", low, year); michael@0: #endif michael@0: // Now we've found the last era that starts before this date, so michael@0: // adjust the year to count from the start of that era. Note that michael@0: // all dates before the first era will fall into the first era by michael@0: // the algorithm. michael@0: michael@0: internalSet(UCAL_ERA, low); michael@0: internalSet(UCAL_YEAR, year - kEraInfo[low].year + 1); michael@0: #ifdef U_DEBUG_JCAL michael@0: fprintf(stderr, " Set ERA=%d, year=%d\n", low, year-kEraInfo[low].year+1); michael@0: #endif michael@0: michael@0: } michael@0: michael@0: /* michael@0: Disable pivoting michael@0: */ michael@0: UBool JapaneseCalendar::haveDefaultCentury() const michael@0: { michael@0: return FALSE; michael@0: } michael@0: michael@0: UDate JapaneseCalendar::defaultCenturyStart() const michael@0: { michael@0: return 0;// WRONG michael@0: } michael@0: michael@0: int32_t JapaneseCalendar::defaultCenturyStartYear() const michael@0: { michael@0: return 0; michael@0: } michael@0: michael@0: int32_t JapaneseCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) const michael@0: { michael@0: switch(field) { michael@0: case UCAL_ERA: michael@0: if (limitType == UCAL_LIMIT_MINIMUM || limitType == UCAL_LIMIT_GREATEST_MINIMUM) { michael@0: return 0; michael@0: } michael@0: return kCurrentEra; michael@0: case UCAL_YEAR: michael@0: { michael@0: switch (limitType) { michael@0: case UCAL_LIMIT_MINIMUM: michael@0: case UCAL_LIMIT_GREATEST_MINIMUM: michael@0: return 1; michael@0: case UCAL_LIMIT_LEAST_MAXIMUM: michael@0: return 1; michael@0: case UCAL_LIMIT_COUNT: //added to avoid warning michael@0: case UCAL_LIMIT_MAXIMUM: michael@0: return GregorianCalendar::handleGetLimit(UCAL_YEAR, UCAL_LIMIT_MAXIMUM) - kEraInfo[kCurrentEra].year; michael@0: default: michael@0: return 1; // Error condition, invalid limitType michael@0: } michael@0: } michael@0: default: michael@0: return GregorianCalendar::handleGetLimit(field,limitType); michael@0: } michael@0: } michael@0: michael@0: int32_t JapaneseCalendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const { michael@0: if (field == UCAL_YEAR) { michael@0: int32_t era = get(UCAL_ERA, status); michael@0: if (U_FAILURE(status)) { michael@0: return 0; // error case... any value michael@0: } michael@0: if (era == kCurrentEra) { michael@0: // TODO: Investigate what value should be used here - revisit after 4.0. michael@0: return handleGetLimit(UCAL_YEAR, UCAL_LIMIT_MAXIMUM); michael@0: } else { michael@0: int32_t nextEraYear = kEraInfo[era + 1].year; michael@0: int32_t nextEraMonth = kEraInfo[era + 1].month; michael@0: int32_t nextEraDate = kEraInfo[era + 1].day; michael@0: michael@0: int32_t maxYear = nextEraYear - kEraInfo[era].year + 1; // 1-base michael@0: if (nextEraMonth == 1 && nextEraDate == 1) { michael@0: // Subtract 1, because the next era starts at Jan 1 michael@0: maxYear--; michael@0: } michael@0: return maxYear; michael@0: } michael@0: } michael@0: return GregorianCalendar::getActualMaximum(field, status); michael@0: } michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif