From 53499c0d6515494a7988db11bf2380de24e9059f Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Mon, 23 Sep 2013 05:30:39 +0000 Subject: [PATCH] ICU-8449 ICU4C Islamic Umm Al-Qura calendar updates based on Yoshito's review. X-SVN-Rev: 34446 --- icu4c/source/i18n/islamcal.cpp | 283 ++++++++++++++++--------- icu4c/source/i18n/islamcal.h | 149 +------------ icu4c/source/test/intltest/caltest.cpp | 18 +- icu4c/source/test/intltest/caltest.h | 4 +- 4 files changed, 208 insertions(+), 246 deletions(-) diff --git a/icu4c/source/i18n/islamcal.cpp b/icu4c/source/i18n/islamcal.cpp index c5a4838f86..9ecc7ed12a 100644 --- a/icu4c/source/i18n/islamcal.cpp +++ b/icu4c/source/i18n/islamcal.cpp @@ -74,58 +74,151 @@ U_NAMESPACE_BEGIN // Implementation of the IslamicCalendar class +/** + * Friday EPOC + */ +static const int32_t CIVIL_EPOC = 1948440; + +/** + * Thursday EPOC + */ +static const int32_t ASTRONOMICAL_EPOC = 1948439; + + +static const int32_t UMALQURA_YEAR_START = 1318; +static const int32_t UMALQURA_YEAR_END = 1480; + +static const int UMALQURA_MONTHLENGTH[] = { + //* 1318 -1322 */ "0101 0111 0100", "1001 0111 0110", "0100 1011 0111", "0010 0101 0111", "0101 0010 1011", + 0x0574, 0x0975, 0x06A7, 0x0257, 0x052B, + //* 1323 -1327 */ "0110 1001 0101", "0110 1100 1010", "1010 1101 0101", "0101 0101 1011", "0010 0101 1101", + 0x0695, 0x06CA, 0x0AD5, 0x055B, 0x025B, + //* 1328 -1332 */ "1001 0010 1101", "1100 1001 0101", "1101 0100 1010", "1110 1010 0101", "0110 1101 0010", + 0x092D, 0x0C95, 0x0D4A, 0x0E5B, 0x025B, + //* 1333 -1337 */ "1010 1101 0101", "0101 0101 1010", "1010 1010 1011", "0100 0100 1011", "0110 1010 0101", + 0x0AD5, 0x055A, 0x0AAB, 0x044B, 0x06A5, + //* 1338 -1342 */ "0111 0101 0010", "1011 1010 1001", "0011 0111 0100", "1010 1011 0110", "0101 0101 0110", + 0x0752, 0x0BA9, 0x0374, 0x0AB6, 0x0556, + //* 1343 -1347 */ "1010 1010 1010", "1101 0101 0010", "1101 1010 1001", "0101 1101 0100", "1010 1110 1010", + 0x0AAA, 0x0D52, 0x0DA9, 0x05D4, 0x0AEA, + //* 1348 -1352 */ "0100 1101 1101", "0010 0110 1110", "1001 0010 1110", "1010 1010 0110", "1101 0101 0100", + 0x04DD, 0x026E, 0x092E, 0x0AA6, 0x0D54, + //* 1353 -1357 */ "0101 1010 1010", "0101 1011 0101", "0010 1011 0100", "1001 0011 0111", "0100 1001 1011", + 0x05AA, 0x05B5, 0x02B4, 0x0937, 0x049B, + //* 1358 -1362 */ "1010 0100 1011", "1011 0010 0101", "1011 0101 0100", "1011 0110 1010", "0101 0110 1101", + 0x0A4B, 0x0B25, 0x0B54, 0x0B6A, 0x056D, + //* 1363 -1367 */ "0100 1010 1101", "1010 0101 0101", "1101 0010 0101", "1110 1001 0010", "1110 1100 1001", + 0x04AD, 0x0A55, 0x0D25, 0x0E92, 0x0EC9, + //* 1368 -1372 */ "0110 1101 0100", "1010 1110 1010", "0101 0110 1011", "0100 1010 1011", "0110 1000 0101", + 0x06D4, 0x0ADA, 0x056B, 0x04AB, 0x0685, + //* 1373 -1377 */ "1011 0100 1001", "1011 1010 0100", "1011 1011 0010", "0101 1011 0101", "0010 1011 1010", + 0x0B49, 0x0BA4, 0x0BB2, 0x05B5, 0x02BA, + //* 1378 -1382 */ "1001 0101 1011", "0100 1010 1011", "0101 0101 0101", "0110 1011 0010", "0110 1101 1001", + 0x095B, 0x04AB, 0x0555, 0x06B2, 0x06D9, + //* 1383 -1387 */ "0010 1110 1100", "1001 0110 1110", "0100 1010 1110", "1010 0101 0110", "1101 0010 1010", + 0x02EC, 0x096E, 0x04AE, 0x0A56, 0x0D2A, + //* 1388 -1392 */ "1101 0101 0101", "0101 1010 1010", "1010 1011 0101", "0100 1011 1011", "0000 0101 1011", + 0x0D55, 0x05AA, 0x0AB5, 0x04BB, 0x005B, + //* 1393 -1397 */ "1001 0010 1011", "1010 1001 0101", "0011 0100 1010", "1011 1010 0101", "0101 1010 1010", + 0x092B, 0x0A95, 0x034A, 0x0BA5, 0x05AA, + //* 1398 -1402 */ "1010 1011 0101", "0101 0101 0110", "1010 1001 0110", "1101 0100 1010", "1110 1010 0101", + 0x0AB5, 0x0556, 0x0A96, 0x0B4A, 0x0EA5, + //* 1403 -1407 */ "0111 0101 0010", "0110 1110 1001", "0011 0110 1010", "1010 1010 1101", "0101 0101 0101", + 0x0752, 0x06E9, 0x036A, 0x0AAD, 0x0555, + //* 1408 -1412 */ "1010 1010 0101", "1011 0101 0010", "1011 1010 1001", "0101 1011 0100", "1001 1011 1010", + 0x0AA5, 0x0B52, 0x0BA9, 0x05B4, 0x09BA, + //* 1413 -1417 */ "0100 1101 1011", "0010 0101 1101", "0101 0010 1101", "1010 1010 0101", "1010 1101 0100", + 0x04DB, 0x025D, 0x052D, 0x0AA5, 0x0AD4, + //* 1418 -1422 */ "1010 1110 1010", "0101 0110 1101", "0100 1011 1101", "0010 0011 1101", "1001 0001 1101", + 0x0AEA, 0x056D, 0x04BD, 0x023D, 0x091D, + //* 1423 -1427 */ "1010 1001 0101", "1011 0100 1010", "1011 0101 1010", "0101 0110 1101", "0010 1011 0110", + 0x0A95, 0x0B4A, 0x0B5A, 0x056D, 0x02B6, + //* 1428 -1432 */ "1001 0011 1011", "0100 1001 1011", "0110 0101 0101", "0110 1010 1001", "0111 0101 0100", + 0x093B, 0x049B, 0x0655, 0x06A9, 0x0754, + //* 1433 -1437 */ "1011 0110 1010", "0101 0110 1100", "1010 1010 1101", "0101 0101 0101", "1011 0010 1001", + 0x0B6A, 0x056C, 0x0AAD, 0x0555, 0x0B29, + //* 1438 -1442 */ "1011 1001 0010", "1011 1010 1001", "0101 1101 0100", "1010 1101 1010", "0101 0101 1010", + 0x0B92, 0x0BA9, 0x05D4, 0x0ADA, 0x055A, + //* 1443 -1447 */ "1010 1010 1011", "0101 1001 0101", "0111 0100 1001", "0111 0110 0100", "1011 1010 1010", + 0x0AAB, 0x0595, 0x0749, 0x0764, 0x0BAA, + //* 1448 -1452 */ "0101 1011 0101", "0010 1011 0110", "1010 0101 0110", "1110 0100 1101", "1011 0010 0101", + 0x05B5, 0x02B6, 0x0A56, 0x0E4D, 0x0B25, + //* 1453 -1457 */ "1011 0101 0010", "1011 0110 1010", "0101 1010 1101", "0010 1010 1110", "1001 0010 1111", + 0x0B52, 0x0B6A, 0x05AD, 0x02AE, 0x092F, + //* 1458 -1462 */ "0100 1001 0111", "0110 0100 1011", "0110 1010 0101", "0110 1010 1100", "1010 1101 0110", + 0x0497, 0x064B, 0x06A5, 0x06AC, 0x0AD6, + //* 1463 -1467 */ "0101 0101 1101", "0100 1001 1101", "1010 0100 1101", "1101 0001 0110", "1101 1001 0101", + 0x055D, 0x049D, 0x0A4D, 0x0D16, 0x0D95, + //* 1468 -1472 */ "0101 1010 1010", "0101 1011 0101", "0010 1001 1010", "1001 0101 1011", "0100 1010 1100", + 0x05AA, 0x05B5, 0x029A, 0x095B, 0x04AC, + //* 1473 -1477 */ "0101 1001 0101", "0110 1100 1010", "0110 1110 0100", "1010 1110 1010", "0100 1111 0101", + 0x0595, 0x06CA, 0x06E4, 0x0AEA, 0x04F5, + //* 1478 -1480 */ "0010 1011 0110", "1001 0101 0110", "1010 1010 1010" + 0x02B6, 0x0956, 0x0AAA +}; + +int32_t getUmalqura_MonthLength(int32_t y, int32_t m) { + int32_t mask = (int32_t) (0x01 << (11 - m)); // set mask for bit corresponding to month + if((UMALQURA_MONTHLENGTH[y] & mask) == 0 ) + return 29; + else + return 30; + +} + //------------------------------------------------------------------------- // Constructors... //------------------------------------------------------------------------- -const char *IslamicCalendar::getType() const { - if(civil==CIVIL) { - return "islamic-civil"; - } else if(civil==ASTRONOMICAL){ - return "islamic"; - } else if(civil==TBLA){ - return "islamic-tbla"; - } else if(civil==UMALQURA){ - return "islamic-umalqura"; - } else { - U_ASSERT(false); // out of range - return "islamic-unknown"; +const char *IslamicCalendar::getType() const { + const char *sType = NULL; + + switch (cType) { + case CIVIL: + sType = "islamic-civil"; + break; + case ASTRONOMICAL: + sType = "islamic"; + break; + case TBLA: + sType = "islamic-tbla"; + break; + case UMALQURA: + sType = "islamic-umalqura"; + break; + default: + U_ASSERT(false); // out of range + sType = "islamic"; // "islamic" is used as the generic type + break; } + return sType; } Calendar* IslamicCalendar::clone() const { return new IslamicCalendar(*this); } -IslamicCalendar::IslamicCalendar(const Locale& aLocale, UErrorCode& success, ECivil beCivil) +IslamicCalendar::IslamicCalendar(const Locale& aLocale, UErrorCode& success, ECalculationType type) : Calendar(TimeZone::createDefault(), aLocale, success), -civil(beCivil) +cType(type) { setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly. } -IslamicCalendar::IslamicCalendar(const IslamicCalendar& other) : Calendar(other), civil(other.civil) { +IslamicCalendar::IslamicCalendar(const IslamicCalendar& other) : Calendar(other), cType(other.cType) { } IslamicCalendar::~IslamicCalendar() { } -/** -* Determines whether this object uses the fixed-cycle Islamic civil calendar -* or an approximation of the religious, astronomical calendar. -* -* @param beCivil true to use the civil calendar, -* false to use the astronomical calendar. -* @draft ICU 2.4 -*/ -void IslamicCalendar::setCivil(ECivil beCivil, UErrorCode &status) +void IslamicCalendar::setCalculationType(ECalculationType type, UErrorCode &status) { - if (civil != beCivil) { + if (cType != type) { // The fields of the calendar will become invalid, because the calendar // rules are different UDate m = getTimeInMillis(status); - civil = beCivil; + cType = type; clear(); setTimeInMillis(m, status); } @@ -138,7 +231,7 @@ void IslamicCalendar::setCivil(ECivil beCivil, UErrorCode &status) * @draft ICU 2.4 */ UBool IslamicCalendar::isCivil() { - return (civil == CIVIL); + return (cType == CIVIL); } //------------------------------------------------------------------------- @@ -204,20 +297,20 @@ UBool IslamicCalendar::civilLeapYear(int32_t year) * from the Hijri epoch, origin 0. */ int32_t IslamicCalendar::yearStart(int32_t year) const{ - if (civil == CIVIL || civil == TBLA || - (civil == UMALQURA && year < UMALQURA_YEAR_START)) - { + if (cType == CIVIL || cType == TBLA || + (cType == UMALQURA && year < UMALQURA_YEAR_START)) + { return (year-1)*354 + ClockMath::floorDivide((3+11*year),30); - } else if(civil==ASTRONOMICAL){ + } else if(cType==ASTRONOMICAL){ return trueMonthStart(12*(year-1)); } else { - int32_t ys = yearStart(UMALQURA_YEAR_START-1); - ys+= handleGetYearLength(UMALQURA_YEAR_START-1); - for(int i=UMALQURA_YEAR_START; i< year; i++){ - ys+= handleGetYearLength(i); + int32_t ys = yearStart(UMALQURA_YEAR_START-1); + ys+= handleGetYearLength(UMALQURA_YEAR_START-1); + for(int i=UMALQURA_YEAR_START; i< year; i++){ + ys+= handleGetYearLength(i); } - return ys; - } + return ys; + } } /** @@ -228,18 +321,18 @@ int32_t IslamicCalendar::yearStart(int32_t year) const{ * @param year The hijri month, 0-based */ int32_t IslamicCalendar::monthStart(int32_t year, int32_t month) const { - if (civil == CIVIL || civil == TBLA) { + if (cType == CIVIL || cType == TBLA) { return (int32_t)uprv_ceil(29.5*month) + (year-1)*354 + (int32_t)ClockMath::floorDivide((3+11*year),30); - } else if(civil==ASTRONOMICAL){ + } else if(cType==ASTRONOMICAL){ return trueMonthStart(12*(year-1) + month); } else { - int32_t ms = yearStart(year); + int32_t ms = yearStart(year); for(int i=0; i< month; i++){ - ms+= handleGetMonthLength(year, i); + ms+= handleGetMonthLength(year, i); } - return ms; - } + return ms; + } } /** @@ -346,18 +439,18 @@ int32_t IslamicCalendar::handleGetMonthLength(int32_t extendedYear, int32_t mont int32_t length = 0; - if (civil == CIVIL || civil == TBLA || - (civil == UMALQURA && (extendedYearUMALQURA_YEAR_END)) ) { + if (cType == CIVIL || cType == TBLA || + (cType == UMALQURA && (extendedYearUMALQURA_YEAR_END)) ) { length = 29 + (month+1) % 2; if (month == DHU_AL_HIJJAH && civilLeapYear(extendedYear)) { length++; } - } else if(civil == ASTRONOMICAL){ + } else if(cType == ASTRONOMICAL){ month = 12*(extendedYear-1) + month; length = trueMonthStart(month+1) - trueMonthStart(month) ; } else { length = getUmalqura_MonthLength(extendedYear - UMALQURA_YEAR_START, month); - } + } return length; } @@ -366,18 +459,18 @@ int32_t IslamicCalendar::handleGetMonthLength(int32_t extendedYear, int32_t mont * @draft ICU 2.4 */ int32_t IslamicCalendar::handleGetYearLength(int32_t extendedYear) const { - if (civil == CIVIL || civil == TBLA || - (civil == UMALQURA && (extendedYearUMALQURA_YEAR_END)) ) { + if (cType == CIVIL || cType == TBLA || + (cType == UMALQURA && (extendedYearUMALQURA_YEAR_END)) ) { return 354 + (civilLeapYear(extendedYear) ? 1 : 0); - } else if(civil == ASTRONOMICAL){ + } else if(cType == ASTRONOMICAL){ int32_t month = 12*(extendedYear-1); return (trueMonthStart(month + 12) - trueMonthStart(month)); } else { - int len = 0; - for(int i=0; i<12; i++) - len += handleGetMonthLength(extendedYear, i); - return len; - } + int len = 0; + for(int i=0; i<12; i++) + len += handleGetMonthLength(extendedYear, i); + return len; + } } //------------------------------------------------------------------------- @@ -430,15 +523,15 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) UDate startDate; int32_t days = julianDay - CIVIL_EPOC; - if (civil == CIVIL || civil == TBLA) { - if(civil == TBLA) + if (cType == CIVIL || cType == TBLA) { + if(cType == TBLA) days = julianDay - ASTRONOMICAL_EPOC; // Use the civil calendar approximation, which is just arithmetic year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 ); month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 ); month = month<11?month:11; startDate = monthStart(year, month); - } else if(civil == ASTRONOMICAL){ + } else if(cType == ASTRONOMICAL){ // Guess at the number of elapsed full months since the epoch int32_t months = (int32_t)uprv_floor((double)days / CalendarAstronomer::SYNODIC_MONTH); @@ -446,8 +539,8 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) double age = moonAge(internalGetTime(), status); if (U_FAILURE(status)) { - status = U_MEMORY_ALLOCATION_ERROR; - return; + status = U_MEMORY_ALLOCATION_ERROR; + return; } if ( days - startDate >= 25 && age > 0) { // If we're near the end of the month, assume next month and search backwards @@ -463,47 +556,47 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) year = months / 12 + 1; month = months % 12; - } else if(civil == UMALQURA) { - int32_t umalquraStartdays = yearStart(UMALQURA_YEAR_START) ; - if( days < umalquraStartdays){ - //Use Civil calculation - year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 ); - month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 ); - month = month<11?month:11; - startDate = monthStart(year, month); - }else{ - int y =UMALQURA_YEAR_START-1, m =0; - long d = 1; - while(d > 0){ - y++; - d = days - yearStart(y) +1; - if(d == handleGetYearLength(y)){ - m=11; - break; - }else if(d < handleGetYearLength(y) ){ - int monthLen = handleGetMonthLength(y, m); - m=0; - while(d > monthLen){ - d -= monthLen; - m++; - monthLen = handleGetMonthLength(y, m); - } - break; - } - } - year = y; - month = m; - } + } else if(cType == UMALQURA) { + int32_t umalquraStartdays = yearStart(UMALQURA_YEAR_START) ; + if( days < umalquraStartdays){ + //Use Civil calculation + year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 ); + month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 ); + month = month<11?month:11; + startDate = monthStart(year, month); + }else{ + int y =UMALQURA_YEAR_START-1, m =0; + long d = 1; + while(d > 0){ + y++; + d = days - yearStart(y) +1; + if(d == handleGetYearLength(y)){ + m=11; + break; + }else if(d < handleGetYearLength(y) ){ + int monthLen = handleGetMonthLength(y, m); + m=0; + while(d > monthLen){ + d -= monthLen; + m++; + monthLen = handleGetMonthLength(y, m); + } + break; + } + } + year = y; + month = m; + } } else { // invalid 'civil' U_ASSERT(false); // should not get here, out of range year=month=0; } - dayOfMonth = (days - monthStart(year, month)) + 1; + dayOfMonth = (days - monthStart(year, month)) + 1; + + // Now figure out the day of the year. + dayOfYear = (days - monthStart(year, 0) + 1); - // Now figure out the day of the year. - dayOfYear = (days - monthStart(year, 0) + 1); - internalSet(UCAL_ERA, 0); internalSet(UCAL_YEAR, year); diff --git a/icu4c/source/i18n/islamcal.h b/icu4c/source/i18n/islamcal.h index 3578560683..75f9656de9 100644 --- a/icu4c/source/i18n/islamcal.h +++ b/icu4c/source/i18n/islamcal.h @@ -91,7 +91,7 @@ class U_I18N_API IslamicCalendar : public Calendar { * Calendar type - civil or religious or um alqura * @internal */ - enum ECivil { + enum ECalculationType { ASTRONOMICAL, CIVIL, UMALQURA, @@ -190,10 +190,10 @@ class U_I18N_API IslamicCalendar : public Calendar { * @param aLocale The given locale. * @param success Indicates the status of IslamicCalendar object construction. * Returns U_ZERO_ERROR if constructed successfully. - * @param beCivil Whether the calendar should be civil (default-TRUE) or religious (FALSE) + * @param type The Islamic calendar calculation type. The default value is CIVIL. * @internal */ - IslamicCalendar(const Locale& aLocale, UErrorCode &success, ECivil beCivil = CIVIL); + IslamicCalendar(const Locale& aLocale, UErrorCode &success, ECalculationType type = CIVIL); /** * Copy Constructor @@ -208,14 +208,13 @@ class U_I18N_API IslamicCalendar : public Calendar { virtual ~IslamicCalendar(); /** - * Determines whether this object uses the fixed-cycle Islamic civil calendar - * or an approximation of the religious, astronomical calendar. + * Sets Islamic calendar calculation type used by this instance. * - * @param beCivil CIVIL to use the civil calendar, - * ASTRONOMICAL to use the astronomical calendar. + * @param type The calendar calculation type, CIVIL to use the civil + * calendar, ASTRONOMICAL to use the astronomical calendar. * @internal */ - void setCivil(ECivil beCivil, UErrorCode &status); + void setCalculationType(ECalculationType type, UErrorCode &status); /** * Returns true if this object is using the fixed-cycle civil @@ -282,7 +281,7 @@ class U_I18N_API IslamicCalendar : public Calendar { * and ASTRONOMICAL if it approximates the true religious calendar using * astronomical calculations for the time of the new moon. */ - ECivil civil; + ECalculationType cType; //---------------------------------------------------------------------- // Calendar framework @@ -412,137 +411,7 @@ class U_I18N_API IslamicCalendar : public Calendar { */ virtual int32_t defaultCenturyStartYear() const; - private: // default century stuff. - /** - * The system maintains a static default century start date. This is initialized - * the first time it is used. Before then, it is set to SYSTEM_DEFAULT_CENTURY to - * indicate an uninitialized state. Once the system default century date and year - * are set, they do not change. - */ - static UDate fgSystemDefaultCenturyStart; - - /** - * See documentation for systemDefaultCenturyStart. - */ - static int32_t fgSystemDefaultCenturyStartYear; - - - /** - * Default value that indicates the defaultCenturyStartYear is unitialized - */ - static const int32_t fgSystemDefaultCenturyYear; - - /** - * start of default century, as a date - */ - static const UDate fgSystemDefaultCentury; - - static const int32_t UMALQURA_YEAR_START = 1318; - static const int32_t UMALQURA_YEAR_END = 1480; - - - /** - * Friday EPOC - */ - static const int32_t CIVIL_EPOC = 1948440; - - /** - * Thursday EPOC - */ - static const int32_t ASTRONOMICAL_EPOC = 1948439; - - - static int getUmalqura_MonthLength(int i, int j){ - - static const int UMALQURA_MONTHLENGTH[] = { - //* 1318 -1322 */ "0101 0111 0100", "1001 0111 0110", "0100 1011 0111", "0010 0101 0111", "0101 0010 1011", - 0x0574, 0x0975, 0x06A7, 0x0257, 0x052B, - //* 1323 -1327 */ "0110 1001 0101", "0110 1100 1010", "1010 1101 0101", "0101 0101 1011", "0010 0101 1101", - 0x0695, 0x06CA, 0x0AD5, 0x055B, 0x025B, - //* 1328 -1332 */ "1001 0010 1101", "1100 1001 0101", "1101 0100 1010", "1110 1010 0101", "0110 1101 0010", - 0x092D, 0x0C95, 0x0D4A, 0x0E5B, 0x025B, - //* 1333 -1337 */ "1010 1101 0101", "0101 0101 1010", "1010 1010 1011", "0100 0100 1011", "0110 1010 0101", - 0x0AD5, 0x055A, 0x0AAB, 0x044B, 0x06A5, - //* 1338 -1342 */ "0111 0101 0010", "1011 1010 1001", "0011 0111 0100", "1010 1011 0110", "0101 0101 0110", - 0x0752, 0x0BA9, 0x0374, 0x0AB6, 0x0556, - //* 1343 -1347 */ "1010 1010 1010", "1101 0101 0010", "1101 1010 1001", "0101 1101 0100", "1010 1110 1010", - 0x0AAA, 0x0D52, 0x0DA9, 0x05D4, 0x0AEA, - //* 1348 -1352 */ "0100 1101 1101", "0010 0110 1110", "1001 0010 1110", "1010 1010 0110", "1101 0101 0100", - 0x04DD, 0x026E, 0x092E, 0x0AA6, 0x0D54, - //* 1353 -1357 */ "0101 1010 1010", "0101 1011 0101", "0010 1011 0100", "1001 0011 0111", "0100 1001 1011", - 0x05AA, 0x05B5, 0x02B4, 0x0937, 0x049B, - //* 1358 -1362 */ "1010 0100 1011", "1011 0010 0101", "1011 0101 0100", "1011 0110 1010", "0101 0110 1101", - 0x0A4B, 0x0B25, 0x0B54, 0x0B6A, 0x056D, - //* 1363 -1367 */ "0100 1010 1101", "1010 0101 0101", "1101 0010 0101", "1110 1001 0010", "1110 1100 1001", - 0x04AD, 0x0A55, 0x0D25, 0x0E92, 0x0EC9, - //* 1368 -1372 */ "0110 1101 0100", "1010 1110 1010", "0101 0110 1011", "0100 1010 1011", "0110 1000 0101", - 0x06D4, 0x0ADA, 0x056B, 0x04AB, 0x0685, - //* 1373 -1377 */ "1011 0100 1001", "1011 1010 0100", "1011 1011 0010", "0101 1011 0101", "0010 1011 1010", - 0x0B49, 0x0BA4, 0x0BB2, 0x05B5, 0x02BA, - //* 1378 -1382 */ "1001 0101 1011", "0100 1010 1011", "0101 0101 0101", "0110 1011 0010", "0110 1101 1001", - 0x095B, 0x04AB, 0x0555, 0x06B2, 0x06D9, - //* 1383 -1387 */ "0010 1110 1100", "1001 0110 1110", "0100 1010 1110", "1010 0101 0110", "1101 0010 1010", - 0x02EC, 0x096E, 0x04AE, 0x0A56, 0x0D2A, - //* 1388 -1392 */ "1101 0101 0101", "0101 1010 1010", "1010 1011 0101", "0100 1011 1011", "0000 0101 1011", - 0x0D55, 0x05AA, 0x0AB5, 0x04BB, 0x005B, - //* 1393 -1397 */ "1001 0010 1011", "1010 1001 0101", "0011 0100 1010", "1011 1010 0101", "0101 1010 1010", - 0x092B, 0x0A95, 0x034A, 0x0BA5, 0x05AA, - //* 1398 -1402 */ "1010 1011 0101", "0101 0101 0110", "1010 1001 0110", "1101 0100 1010", "1110 1010 0101", - 0x0AB5, 0x0556, 0x0A96, 0x0B4A, 0x0EA5, - //* 1403 -1407 */ "0111 0101 0010", "0110 1110 1001", "0011 0110 1010", "1010 1010 1101", "0101 0101 0101", - 0x0752, 0x06E9, 0x036A, 0x0AAD, 0x0555, - //* 1408 -1412 */ "1010 1010 0101", "1011 0101 0010", "1011 1010 1001", "0101 1011 0100", "1001 1011 1010", - 0x0AA5, 0x0B52, 0x0BA9, 0x05B4, 0x09BA, - //* 1413 -1417 */ "0100 1101 1011", "0010 0101 1101", "0101 0010 1101", "1010 1010 0101", "1010 1101 0100", - 0x04DB, 0x025D, 0x052D, 0x0AA5, 0x0AD4, - //* 1418 -1422 */ "1010 1110 1010", "0101 0110 1101", "0100 1011 1101", "0010 0011 1101", "1001 0001 1101", - 0x0AEA, 0x056D, 0x04BD, 0x023D, 0x091D, - //* 1423 -1427 */ "1010 1001 0101", "1011 0100 1010", "1011 0101 1010", "0101 0110 1101", "0010 1011 0110", - 0x0A95, 0x0B4A, 0x0B5A, 0x056D, 0x02B6, - //* 1428 -1432 */ "1001 0011 1011", "0100 1001 1011", "0110 0101 0101", "0110 1010 1001", "0111 0101 0100", - 0x093B, 0x049B, 0x0655, 0x06A9, 0x0754, - //* 1433 -1437 */ "1011 0110 1010", "0101 0110 1100", "1010 1010 1101", "0101 0101 0101", "1011 0010 1001", - 0x0B6A, 0x056C, 0x0AAD, 0x0555, 0x0B29, - //* 1438 -1442 */ "1011 1001 0010", "1011 1010 1001", "0101 1101 0100", "1010 1101 1010", "0101 0101 1010", - 0x0B92, 0x0BA9, 0x05D4, 0x0ADA, 0x055A, - //* 1443 -1447 */ "1010 1010 1011", "0101 1001 0101", "0111 0100 1001", "0111 0110 0100", "1011 1010 1010", - 0x0AAB, 0x0595, 0x0749, 0x0764, 0x0BAA, - //* 1448 -1452 */ "0101 1011 0101", "0010 1011 0110", "1010 0101 0110", "1110 0100 1101", "1011 0010 0101", - 0x05B5, 0x02B6, 0x0A56, 0x0E4D, 0x0B25, - //* 1453 -1457 */ "1011 0101 0010", "1011 0110 1010", "0101 1010 1101", "0010 1010 1110", "1001 0010 1111", - 0x0B52, 0x0B6A, 0x05AD, 0x02AE, 0x092F, - //* 1458 -1462 */ "0100 1001 0111", "0110 0100 1011", "0110 1010 0101", "0110 1010 1100", "1010 1101 0110", - 0x0497, 0x064B, 0x06A5, 0x06AC, 0x0AD6, - //* 1463 -1467 */ "0101 0101 1101", "0100 1001 1101", "1010 0100 1101", "1101 0001 0110", "1101 1001 0101", - 0x055D, 0x049D, 0x0A4D, 0x0D16, 0x0D95, - //* 1468 -1472 */ "0101 1010 1010", "0101 1011 0101", "0010 1001 1010", "1001 0101 1011", "0100 1010 1100", - 0x05AA, 0x05B5, 0x029A, 0x095B, 0x04AC, - //* 1473 -1477 */ "0101 1001 0101", "0110 1100 1010", "0110 1110 0100", "1010 1110 1010", "0100 1111 0101", - 0x0595, 0x06CA, 0x06E4, 0x0AEA, 0x04F5, - //* 1478 -1480 */ "0010 1011 0110", "1001 0101 0110", "1010 1010 1010" - 0x02B6, 0x0956, 0x0AAA - }; - - int mask = (int) (0x01 << (11 - j)); // set mask for bit corresponding to month - if((UMALQURA_MONTHLENGTH[i] & mask) == 0 ) - return 29; - else - return 30; - } - - - /** - * Returns the beginning date of the 100-year window that dates - * with 2-digit years are considered to fall within. - */ - UDate internalGetDefaultCenturyStart(void) const; - - /** - * Returns the first year of the 100-year window that dates with - * 2-digit years are considered to fall within. - */ - int32_t internalGetDefaultCenturyStartYear(void) const; - + private: /** * Initializes the 100-year window that dates with 2-digit years * are considered to fall within so that its start date is 80 years diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp index 9ad2b345ff..6fcd3a6366 100644 --- a/icu4c/source/test/intltest/caltest.cpp +++ b/icu4c/source/test/intltest/caltest.cpp @@ -284,14 +284,14 @@ void CalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &name, TestCloneLocale(); } break; - case 31: - name = "Test8449"; + case 31: + name = "TestIslamicUmAlQura"; if(exec) { - logln("Test8449---"); logln(""); - Test8449(); + logln("TestIslamicUmAlQura---"); logln(""); + TestIslamicUmAlQura(); } break; - case 32: + case 32: name = "TestIslamicTabularDates"; if(exec) { logln("TestIslamicTabularDates---"); logln(""); @@ -2766,11 +2766,11 @@ void CalendarTest::setAndTestWholeYear(Calendar* cal, int32_t startYear, UErrorC } -void CalendarTest::Test8449() { +void CalendarTest::TestIslamicUmAlQura() { UErrorCode status = U_ZERO_ERROR; Locale islamicLoc("ar_SA@calendar=islamic-umalqura"); - Calendar* tstCal = Calendar::createInstance(islamicLoc, status); + Calendar* tstCal = Calendar::createInstance(islamicLoc, status); IslamicCalendar* iCal = (IslamicCalendar*)tstCal; if(strcmp(iCal->getType(), "islamic-umalqura") != 0) { @@ -2861,7 +2861,7 @@ void CalendarTest::TestIslamicTabularDates() { SimpleDateFormat* formatter = new SimpleDateFormat("yyyy-MM-dd", Locale::getUS(), status); UDate date = formatter->parse("1975-05-06", status); - Calendar* tstCal = Calendar::createInstance(islamicLoc, status); + Calendar* tstCal = Calendar::createInstance(islamicLoc, status); tstCal->setTime(date, status); int32_t is_day = tstCal->get(UCAL_DAY_OF_MONTH,status); int32_t is_month = tstCal->get(UCAL_MONTH,status); @@ -2869,7 +2869,7 @@ void CalendarTest::TestIslamicTabularDates() { TEST_CHECK_STATUS; delete tstCal; - tstCal = Calendar::createInstance(tblaLoc, status); + tstCal = Calendar::createInstance(tblaLoc, status); tstCal->setTime(date, status); int32_t tbla_day = tstCal->get(UCAL_DAY_OF_MONTH,status); int32_t tbla_month = tstCal->get(UCAL_MONTH,status); diff --git a/icu4c/source/test/intltest/caltest.h b/icu4c/source/test/intltest/caltest.h index 824635d0bd..b96f9a1e06 100644 --- a/icu4c/source/test/intltest/caltest.h +++ b/icu4c/source/test/intltest/caltest.h @@ -219,7 +219,7 @@ public: // package void Test6703(void); void Test3785(void); void Test1624(void); - void Test8449(void); + void TestIslamicUmAlQura(void); void TestIslamicTabularDates(void); /** @@ -241,7 +241,7 @@ public: // package void TestCloneLocale(void); /* - * utility methods for Test8449 + * utility methods for TestIslamicUmAlQura */ void setAndTestCalendar(Calendar* cal, int32_t initMonth, int32_t initDay, int32_t initYear, UErrorCode& status); void setAndTestWholeYear(Calendar* cal, int32_t startYear, UErrorCode& status);