From: Peter Edberg Date: Tue, 3 Oct 2017 20:36:42 +0000 (+0000) Subject: ICU-13366 part 12, fix C SimpleDateFormat::subParse handling of 2-digit years for... X-Git-Tag: release-60-rc~63 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0065725adc3044641f7bb687cb2e2674e1add29a;p=icu ICU-13366 part 12, fix C SimpleDateFormat::subParse handling of 2-digit years for supplemental chars X-SVN-Rev: 40536 --- diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index 402672c0631..cc9e9d3f0e4 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -3056,9 +3056,9 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC // is treated literally: "2250", "-1", "1", "002". if (fDateOverride.compare(hebr)==0 && value < 1000) { value += HEBREW_CAL_CUR_MILLENIUM_START_YEAR; - } else if ((pos.getIndex() - start) == 2 && !isChineseCalendar - && u_isdigit(text.charAt(start)) - && u_isdigit(text.charAt(start+1))) + } else if (text.moveIndex32(start, 2) == pos.getIndex() && !isChineseCalendar + && u_isdigit(text.char32At(start)) + && u_isdigit(text.char32At(text.moveIndex32(start, 1)))) { // only adjust year for patterns less than 3. if(count < 3) { @@ -3096,9 +3096,9 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC // Comment is the same as for UDAT_Year_FIELDs - look above if (fDateOverride.compare(hebr)==0 && value < 1000) { value += HEBREW_CAL_CUR_MILLENIUM_START_YEAR; - } else if ((pos.getIndex() - start) == 2 - && u_isdigit(text.charAt(start)) - && u_isdigit(text.charAt(start+1)) + } else if (text.moveIndex32(start, 2) == pos.getIndex() + && u_isdigit(text.char32At(start)) + && u_isdigit(text.char32At(text.moveIndex32(start, 1))) && fHaveDefaultCentury ) { int32_t ambiguousTwoDigitYear = fDefaultCenturyStartYear % 100; diff --git a/icu4c/source/test/intltest/dtfmtrtts.cpp b/icu4c/source/test/intltest/dtfmtrtts.cpp index 9d5d10ec60e..2206d0fe0d9 100644 --- a/icu4c/source/test/intltest/dtfmtrtts.cpp +++ b/icu4c/source/test/intltest/dtfmtrtts.cpp @@ -249,9 +249,6 @@ void DateFormatRoundTripTest::test(const Locale& loc) for(style = DateFormat::FULL; style <= DateFormat::SHORT; ++style) { if (TEST_TABLE[itable++]) { - if (uprv_strcmp(loc.getLanguage(),"ccp")==0 && style==DateFormat::LONG && logKnownIssue("13366", "Skip handling ccp until DateFormat parsing is fixed")) { - continue; - } logln("Testing style " + UnicodeString(styleName((DateFormat::EStyle)style))); DateFormat *df = DateFormat::createTimeInstance((DateFormat::EStyle)style, loc); if(df == NULL) { @@ -266,9 +263,6 @@ void DateFormatRoundTripTest::test(const Locale& loc) for(int32_t dstyle = DateFormat::FULL; dstyle <= DateFormat::SHORT; ++dstyle) { for(int32_t tstyle = DateFormat::FULL; tstyle <= DateFormat::SHORT; ++tstyle) { if(TEST_TABLE[itable++]) { - if (uprv_strcmp(loc.getLanguage(),"ccp")==0 && tstyle==DateFormat::LONG && logKnownIssue("13366", "Skip handling ccp until DateFormat parsing is fixed")) { - continue; - } logln("Testing dstyle" + UnicodeString(styleName((DateFormat::EStyle)dstyle)) + ", tstyle" + UnicodeString(styleName((DateFormat::EStyle)tstyle)) ); DateFormat *df = DateFormat::createDateTimeInstance((DateFormat::EStyle)dstyle, (DateFormat::EStyle)tstyle, loc); if(df == NULL) { diff --git a/icu4c/source/test/intltest/tsdate.cpp b/icu4c/source/test/intltest/tsdate.cpp index df9988fa57e..596ce97024b 100644 --- a/icu4c/source/test/intltest/tsdate.cpp +++ b/icu4c/source/test/intltest/tsdate.cpp @@ -104,9 +104,6 @@ IntlTestDateFormat::testLocale(/*char* par, */const Locale& locale, const Unicod timeStyle < (DateFormat::EStyle)4; timeStyle = (DateFormat::EStyle) (timeStyle+1)) { - if (uprv_strcmp(locale.getLanguage(),"ccp")==0 && logKnownIssue("13366", "Skip handling ccp until DateFormat parsing is fixed")) { - continue; - } fTestName = (UnicodeString) "DateTime test " + (int32_t) dateStyle + "/" + (int32_t) timeStyle + " (" + localeName + ")"; fFormat = DateFormat::createDateTimeInstance(dateStyle, timeStyle, locale); testFormat(/* par */);