]> granicus.if.org Git - icu/commitdiff
ICU-13446 Fixed Chakma date format fractional seconds parsing problem. Removed logKno...
authorYoshito Umaoka <y.umaoka@gmail.com>
Thu, 26 Oct 2017 22:13:13 +0000 (22:13 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Thu, 26 Oct 2017 22:13:13 +0000 (22:13 +0000)
X-SVN-Rev: 40647

icu4c/source/i18n/smpdtfmt.cpp
icu4c/source/i18n/unicode/smpdtfmt.h
icu4c/source/test/intltest/tzfmttst.cpp

index c4d325cc485b941cb548e92267c78266c39a3532..27fbbd8f7a9ef54166a07afab367bb34f3704e17 100644 (file)
@@ -3202,7 +3202,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
 
     case UDAT_FRACTIONAL_SECOND_FIELD:
         // Fractional seconds left-justify
-        i = pos.getIndex() - start;
+        i = countDigits(text, start, pos.getIndex());
         if (i < 3) {
             while (i < 3) {
                 value *= 10;
@@ -3728,6 +3728,19 @@ void SimpleDateFormat::parseInt(const UnicodeString& text,
     }
 }
 
+int32_t SimpleDateFormat::countDigits(const UnicodeString& text, int32_t start, int32_t end) const {
+    int32_t numDigits = 0;
+    int32_t idx = start;
+    while (idx < end) {
+        UChar32 cp = text.char32At(idx);
+        if (u_isdigit(cp)) {
+            numDigits++;
+        }
+        idx += U16_LENGTH(cp);
+    }
+    return numDigits;
+}
+
 //----------------------------------------------------------------------
 
 void SimpleDateFormat::translatePattern(const UnicodeString& originalPattern,
index 4733e759aa705fdfe01afc6f228d968420d83815..9801b29bdb749bde8bf6f0fda9f02fdeb44f09f5 100644 (file)
@@ -1433,6 +1433,16 @@ private:
     int32_t checkIntSuffix(const UnicodeString& text, int32_t start,
                            int32_t patLoc, UBool isNegative) const;
 
+    /**
+     * Counts number of digit code points in the specified text.
+     *
+     * @param text  input text
+     * @param start start index, inclusive
+     * @param end   end index, exclusive
+     * @return  number of digits found in the text in the specified range.
+    */
+    int32_t countDigits(const UnicodeString& text, int32_t start, int32_t end) const;
+
     /**
      * Translate a pattern, mapping each character in the from string to the
      * corresponding character in the to string. Return an error if the original
index 05c4778a9d6d0e1482203ae0bf0df184ed91bbf6..46a640ae68823eff79e8890962416e8f9d6044f4 100644 (file)
@@ -567,11 +567,6 @@ void TimeZoneFormatTest::RunTimeRoundTripTests(int32_t threadNumber) {
         logln("    Thread %d, Locale %s, Pattern %s", 
                 threadNumber, gLocaleData->locales[locidx].getName(), CStr(pattern)());
 
-        if (uprv_strcmp(gLocaleData->locales[locidx].getLanguage(), "ccp") == 0
-            && logKnownIssue("13446", "Chakma time zone parsing")) {
-            continue;
-        }
-
         SimpleDateFormat *sdf = new SimpleDateFormat(pattern, gLocaleData->locales[locidx], status);
         if (U_FAILURE(status)) {
             errcheckln(status, (UnicodeString) "new SimpleDateFormat failed for pattern " +