]> granicus.if.org Git - icu/commitdiff
ICU-8803 make Calendar::getType() public and improve API docs
authorMarkus Scherer <markus.icu@gmail.com>
Mon, 13 Feb 2012 23:54:23 +0000 (23:54 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Mon, 13 Feb 2012 23:54:23 +0000 (23:54 +0000)
X-SVN-Rev: 31385

icu4c/source/i18n/unicode/calendar.h
icu4c/source/i18n/unicode/gregocal.h

index cf7f7355cd54864614cb4e2af853c1871e4917b4..248eaf9f71d9e27f96cde5c76ba49667e7530d5b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ********************************************************************************
-*   Copyright (C) 1997-2011, International Business Machines
+*   Copyright (C) 1997-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ********************************************************************************
 *
@@ -1195,12 +1195,36 @@ public:
     virtual UClassID getDynamicClassID(void) const = 0;
 
     /**
-     * Returns the resource key string used for this calendar type.
-     * For example, prepending "Eras_" to this string could return "Eras_japanese"
-     * or "Eras_gregorian".
-     *
-     * @returns static string, for example, "gregorian" or "japanese"
-     * @internal
+     * Returns the calendar type name string for this Calendar object.
+     * The returned string is the legacy ICU calendar attribute value,
+     * for example, "gregorian" or "japanese".
+     *
+     * See type="old type name" for the calendar attribute of locale IDs
+     * at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
+     *
+     * Sample code for getting the LDML/BCP 47 calendar key value:
+     * \code
+     * const char *calType = cal->getType();
+     * if (0 == strcmp(calType, "unknown")) {
+     *     // deal with unknown calendar type
+     * } else {
+     *     string localeID("root@calendar=");
+     *     localeID.append(calType);
+     *     char langTag[100];
+     *     UErrorCode errorCode = U_ZERO_ERROR;
+     *     int32_t length = uloc_toLanguageTag(localeID.c_str(), langTag, (int32_t)sizeof(langTag), TRUE, &errorCode);
+     *     if (U_FAILURE(errorCode)) {
+     *         // deal with errors & overflow
+     *     }
+     *     string lang(langTag, length);
+     *     size_t caPos = lang.find("-ca-");
+     *     lang.erase(0, caPos + 4);
+     *     // lang now contains the LDML calendar type
+     * }
+     * \endcode
+     *
+     * @return legacy calendar type name string
+     * @draft ICU 49
      */
     virtual const char * getType() const = 0;
 
index ab83371426f343aac0f30454b9af879a4f1f6435..6ae08edec8eed77d2665b2e118d357096a88b707 100644 (file)
@@ -1,5 +1,5 @@
 /*
-* Copyright (C) 1997-2011, International Business Machines Corporation and others.
+* Copyright (C) 1997-2012, International Business Machines Corporation and others.
 * All Rights Reserved.
 ********************************************************************************
 *
@@ -469,10 +469,14 @@ public:
     static UClassID U_EXPORT2 getStaticClassID(void);
 
     /**
-     * Get the calendar type, "gregorian", for use in DateFormatSymbols.
+     * Returns the calendar type name string for this Calendar object.
+     * The returned string is the legacy ICU calendar attribute value,
+     * for example, "gregorian" or "japanese".
      *
-     * @return calendar type
-     * @internal
+     * For more details see the Calendar::getType() documentation.
+     *
+     * @return legacy calendar type name string
+     * @draft ICU 49
      */
     virtual const char * getType() const;