]> granicus.if.org Git - icu/commitdiff
ICU-11539 C: Delete Calendar fields TIME_SEPARATOR, RELATED_YEAR; adjust accordingly
authorPeter Edberg <pedberg@unicode.org>
Fri, 27 Feb 2015 09:01:31 +0000 (09:01 +0000)
committerPeter Edberg <pedberg@unicode.org>
Fri, 27 Feb 2015 09:01:31 +0000 (09:01 +0000)
X-SVN-Rev: 37091

icu4c/source/i18n/calendar.cpp
icu4c/source/i18n/gregocal.cpp
icu4c/source/i18n/smpdtfmt.cpp
icu4c/source/i18n/unicode/ucal.h
icu4c/source/i18n/unicode/udat.h
icu4c/source/tools/toolutil/udbgutil.cpp

index b7d2d9fe7c3be26ef0d55456a056bd825c1aa6de..d07269d75c8fb0f01939b29d986f5ffe22db2055 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 1997-2014, International Business Machines Corporation and    *
+* Copyright (C) 1997-2015, International Business Machines Corporation and    *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 *
@@ -30,7 +30,6 @@
 
 #if !UCONFIG_NO_FORMATTING
 
-#include "unicode/uchar.h"
 #include "unicode/gregocal.h"
 #include "unicode/basictz.h"
 #include "unicode/simpletz.h"
@@ -638,7 +637,6 @@ static const int32_t kCalendarLimits[UCAL_FIELD_COUNT][4] = {
     { -0x7F000000,  -0x7F000000,    0x7F000000,    0x7F000000  }, // JULIAN_DAY
     {           0,            0, 24*kOneHour-1, 24*kOneHour-1  }, // MILLISECONDS_IN_DAY
     {           0,            0,             1,             1  }, // IS_LEAP_MONTH
-    { UCHAR_MIN_VALUE, UCHAR_MIN_VALUE, UCHAR_MAX_VALUE, UCHAR_MAX_VALUE }, // TIME_SEPARATOR
 };
 
 // Resource bundle tags read by this class
@@ -2691,7 +2689,6 @@ int32_t Calendar::getLimit(UCalendarDateFields field, ELimitType limitType) cons
     case UCAL_JULIAN_DAY:
     case UCAL_MILLISECONDS_IN_DAY:
     case UCAL_IS_LEAP_MONTH:
-    case UCAL_TIME_SEPARATOR:
         return kCalendarLimits[field][limitType];
 
     case UCAL_WEEK_OF_MONTH:
index cab04712e8143fa40208d4a43022ef8e723529eb..5e98605bf92d8a59220a5d5588c62d4edbe6f9c2 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 1997-2014, International Business Machines Corporation and
+* Copyright (C) 1997-2015, International Business Machines Corporation and
 * others. All Rights Reserved.
 *******************************************************************************
 *
@@ -99,7 +99,6 @@ static const int32_t kGregorianCalendarLimits[UCAL_FIELD_COUNT][4] = {
     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
-    {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // TIME_SEPARATOR
 };
 
 /*
index d3f53c74274dfe541432c49b7b47f1a5a2e46a7d..9a7c107aeebd15bad79c2467c35df1bae8e985b2 100644 (file)
@@ -139,9 +139,8 @@ static const UDateFormatField kTimeFields[] = {
     UDAT_HOUR0_FIELD,
     UDAT_MILLISECONDS_IN_DAY_FIELD,
     UDAT_TIMEZONE_RFC_FIELD,
-    UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD,
-    UDAT_TIME_SEPARATOR_FIELD };
-static const int8_t kTimeFieldsCount = 11;
+    UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD };
+static const int8_t kTimeFieldsCount = 10;
 
 
 // This is a pattern-of-last-resort used when we can't load a usable pattern out
@@ -1076,12 +1075,11 @@ SimpleDateFormat::fgCalendarFieldToLevel[] =
     /*sS*/ 70, 80,
     /*z?Y*/ 0, 0, 10,
     /*eug*/ 30, 10, 0,
-    /*A?.*/ 40, 0, 0,
-    /*:*/ 0
+    /*A?.*/ 40, 0, 0
 };
 
 int32_t SimpleDateFormat::getLevelFromChar(UChar ch) {
-    // Map calendar field LETTER into calendar field level.
+    // Map date field LETTER into calendar field level.
     // the larger the level, the smaller the field unit.
     // NOTE: if new fields adds in, the table needs to update.
     static const int32_t mapCharToLevel[] = {
@@ -1166,7 +1164,7 @@ SimpleDateFormat::fgPatternIndexToCalendarField[] =
     /*O*/   UCAL_ZONE_OFFSET,
     /*Xx*/  UCAL_ZONE_OFFSET, UCAL_ZONE_OFFSET,
     /*r*/   UCAL_EXTENDED_YEAR,
-    /*:*/   UCAL_TIME_SEPARATOR,
+    /*:*/   UCAL_FIELD_COUNT, /* => no useful mapping to any calendar field */
 };
 
 // Map index into pattern character string to DateFormat field number
@@ -1402,7 +1400,11 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
     }
 
     UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
-    int32_t value = (patternCharIndex != UDAT_RELATED_YEAR_FIELD)? cal.get(field, status): cal.getRelatedYear(status);
+    int32_t value = 0;
+    // Don't get value unless it is useful
+    if (field < UCAL_FIELD_COUNT) {
+        value = (patternCharIndex != UDAT_RELATED_YEAR_FIELD)? cal.get(field, status): cal.getRelatedYear(status);
+    }
     if (U_FAILURE(status)) {
         return;
     }
@@ -2525,17 +2527,19 @@ int32_t SimpleDateFormat::matchString(const UnicodeString& text,
     }
 
     if (bestMatch >= 0) {
-        // Adjustment for Hebrew Calendar month Adar II
-        if (!strcmp(cal.getType(),"hebrew") && field==UCAL_MONTH && bestMatch==13) {
-            cal.set(field,6);
-        } else {
-            if (field == UCAL_YEAR) {
-                bestMatch++; // only get here for cyclic year names, which match 1-based years 1-60
+        if (field < UCAL_FIELD_COUNT) {
+            // Adjustment for Hebrew Calendar month Adar II
+            if (!strcmp(cal.getType(),"hebrew") && field==UCAL_MONTH && bestMatch==13) {
+                cal.set(field,6);
+            } else {
+                if (field == UCAL_YEAR) {
+                    bestMatch++; // only get here for cyclic year names, which match 1-based years 1-60
+                }
+                cal.set(field, bestMatch);
+            }
+            if (monthPattern != NULL) {
+                cal.set(UCAL_IS_LEAP_MONTH, isLeapMonth);
             }
-            cal.set(field, bestMatch);
-        }
-        if (monthPattern != NULL) {
-            cal.set(UCAL_IS_LEAP_MONTH, isLeapMonth);
         }
 
         return start + bestMatchLength;
@@ -2607,7 +2611,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
     if (currentNumberFormat == NULL) {
         return -start;
     }
-    UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
+    UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex]; // UCAL_FIELD_COUNT if irrelevant
     UnicodeString hebr("hebr", 4, US_INV);
 
     if (numericLeapMonthFormatter != NULL) {
@@ -3234,7 +3238,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
                 data[count++].setTo(alt_sep);
             }
 
-            return matchString(text, start, UCAL_TIME_SEPARATOR, data, count, NULL, cal);
+            return matchString(text, start, UCAL_FIELD_COUNT /* => nothing to set */, data, count, NULL, cal);
         }
 
     default:
index 9088b08483c32c7dda4d0fea78df2b3d0cecd2b7..36828607099a76e16933992a794cce8a900bc6ee 100644 (file)
@@ -423,21 +423,6 @@ enum UCalendarDateFields {
    */
   UCAL_IS_LEAP_MONTH,
 
-#ifndef U_HIDE_DRAFT_API
-  /**
-   * Field number indicating the separator between
-   * <code>HOUR</code>, <code>MINUTE</code> and <code>SECOND</code>.
-   * E.g., at 10:04 the <code>TIME_SEPARATOR</code> is <code>:</code>.
-   * @see #UCAL_HOUR
-   * @see #UCAL_MINUTE
-   * @see #UCAL_SECOND
-   * @draft ICU 55
-   */
-  UCAL_TIME_SEPARATOR,
-#else
-  UCAL_TIME_SEPARATOR_HIDE_DRAFT_API,
-#endif  /* U_HIDE_DRAFT_API */
-
   /**
    * Field count
    * @stable ICU 2.6
index 2c0c120a24dea60e359f409c82d901c3889f8d9a..5add151684154aca24032604cdd1123761d87e3f 100644 (file)
@@ -763,7 +763,7 @@ typedef enum UDateFormatField {
 #ifndef U_HIDE_DRAFT_API
     /**
      * FieldPosition and UFieldPosition selector for ':' time separator,
-     * corresponding to the UCAL_TIME_SEPARATOR field.
+     * no corresponding UCAL_ field.
      * @draft ICU 55
      */
     UDAT_TIME_SEPARATOR_FIELD = 35,
index daeb48cce85f9a3e5c7dac659675e8d2348e2b13..911425c1ade81cc90926e84b1cfa43ff5a8c9af3 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 2007-2014, International Business Machines Corporation and
+ * Copyright (c) 2007-2015, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -106,7 +106,6 @@ static const Field names_UCalendarDateFields[] =
     FIELD_NAME_STR( LEN_UCAL, UCAL_JULIAN_DAY ),
     FIELD_NAME_STR( LEN_UCAL, UCAL_MILLISECONDS_IN_DAY ),
     FIELD_NAME_STR( LEN_UCAL, UCAL_IS_LEAP_MONTH ),
-    FIELD_NAME_STR( LEN_UCAL, UCAL_TIME_SEPARATOR ),
 };