]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/udat.cpp
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / i18n / udat.cpp
index 16d52e4d77f1589d631807e61ca35d81d017e0bf..1af14507de4e6b7db811a9d5615d8312730feea2 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 1996-2012, International Business Machines
+*   Copyright (C) 1996-2013, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 */
@@ -21,6 +21,7 @@
 #include "unicode/numfmt.h"
 #include "unicode/dtfmtsym.h"
 #include "unicode/ustring.h"
+#include "unicode/udisplaycontext.h"
 #include "cpputils.h"
 #include "reldtfmt.h"
 #include "umutex.h"
@@ -138,7 +139,7 @@ udat_open(UDateFormatStyle  timeStyle,
         return (UDateFormat*)fmt;
       } // else fall through.
     }
-    if(timeStyle != UDAT_IGNORE) {
+    if(timeStyle != UDAT_PATTERN) {
         if(locale == 0) {
             fmt = DateFormat::createDateTimeInstance((DateFormat::EStyle)dateStyle,
                 (DateFormat::EStyle)timeStyle);
@@ -431,9 +432,9 @@ udat_getSymbols(const   UDateFormat     *fmt,
     const SimpleDateFormat* sdtfmt;
     const RelativeDateFormat* rdtfmt;
     if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
-       syms = sdtfmt->getDateFormatSymbols();
+        syms = sdtfmt->getDateFormatSymbols();
     } else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
-       syms = rdtfmt->getDateFormatSymbols();
+        syms = rdtfmt->getDateFormatSymbols();
     } else {
         return -1;
     }
@@ -485,6 +486,10 @@ udat_getSymbols(const   UDateFormat     *fmt,
         res = syms->getMonths(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
         break;
 
+    case UDAT_SHORTER_WEEKDAYS:
+        res = syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::SHORT);
+        break;
+
     case UDAT_NARROW_WEEKDAYS:
         res = syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
         break;
@@ -509,6 +514,10 @@ udat_getSymbols(const   UDateFormat     *fmt,
         res = syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::ABBREVIATED);
         break;
 
+    case UDAT_STANDALONE_SHORTER_WEEKDAYS:
+        res = syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::SHORT);
+        break;
+
     case UDAT_STANDALONE_NARROW_WEEKDAYS:
         res = syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::NARROW);
         break;
@@ -546,9 +555,9 @@ udat_countSymbols(    const    UDateFormat                *fmt,
     const SimpleDateFormat* sdtfmt;
     const RelativeDateFormat* rdtfmt;
     if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
-       syms = sdtfmt->getDateFormatSymbols();
+        syms = sdtfmt->getDateFormatSymbols();
     } else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
-       syms = rdtfmt->getDateFormatSymbols();
+        syms = rdtfmt->getDateFormatSymbols();
     } else {
         return 0;
     }
@@ -591,6 +600,10 @@ udat_countSymbols(    const    UDateFormat                *fmt,
         syms->getMonths(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
         break;
 
+    case UDAT_SHORTER_WEEKDAYS:
+        syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::SHORT);
+        break;
+
     case UDAT_NARROW_WEEKDAYS:
         syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
         break;
@@ -615,6 +628,10 @@ udat_countSymbols(    const    UDateFormat                *fmt,
         syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::ABBREVIATED);
         break;
 
+    case UDAT_STANDALONE_SHORTER_WEEKDAYS:
+        syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::SHORT);
+        break;
+
     case UDAT_STANDALONE_NARROW_WEEKDAYS:
         syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::NARROW);
         break;
@@ -753,6 +770,13 @@ public:
         setSymbol(syms->fShortWeekdays, syms->fShortWeekdaysCount, index, value, valueLength, errorCode);
     }
 
+    static void
+        setShorterWeekday(DateFormatSymbols *syms, int32_t index,
+        const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+    {
+        setSymbol(syms->fShorterWeekdays, syms->fShorterWeekdaysCount, index, value, valueLength, errorCode);
+    }
+
     static void
         setNarrowWeekday(DateFormatSymbols *syms, int32_t index,
         const UChar *value, int32_t valueLength, UErrorCode &errorCode)
@@ -774,6 +798,13 @@ public:
         setSymbol(syms->fStandaloneShortWeekdays, syms->fStandaloneShortWeekdaysCount, index, value, valueLength, errorCode);
     }
 
+    static void
+        setStandaloneShorterWeekday(DateFormatSymbols *syms, int32_t index,
+        const UChar *value, int32_t valueLength, UErrorCode &errorCode)
+    {
+        setSymbol(syms->fStandaloneShorterWeekdays, syms->fStandaloneShorterWeekdaysCount, index, value, valueLength, errorCode);
+    }
+
     static void
         setStandaloneNarrowWeekday(DateFormatSymbols *syms, int32_t index,
         const UChar *value, int32_t valueLength, UErrorCode &errorCode)
@@ -880,6 +911,10 @@ udat_setSymbols(    UDateFormat             *format,
         DateFormatSymbolsSingleSetter::setShortWeekday(syms, index, value, valueLength, *status);
         break;
 
+    case UDAT_SHORTER_WEEKDAYS:
+        DateFormatSymbolsSingleSetter::setShorterWeekday(syms, index, value, valueLength, *status);
+        break;
+
     case UDAT_NARROW_WEEKDAYS:
         DateFormatSymbolsSingleSetter::setNarrowWeekday(syms, index, value, valueLength, *status);
         break;
@@ -892,6 +927,10 @@ udat_setSymbols(    UDateFormat             *format,
         DateFormatSymbolsSingleSetter::setStandaloneShortWeekday(syms, index, value, valueLength, *status);
         break;
 
+    case UDAT_STANDALONE_SHORTER_WEEKDAYS:
+        DateFormatSymbolsSingleSetter::setStandaloneShorterWeekday(syms, index, value, valueLength, *status);
+        break;
+
     case UDAT_STANDALONE_NARROW_WEEKDAYS:
         DateFormatSymbolsSingleSetter::setStandaloneNarrowWeekday(syms, index, value, valueLength, *status);
         break;
@@ -943,27 +982,23 @@ udat_getLocaleByType(const UDateFormat *fmt,
 
 
 U_CAPI void U_EXPORT2
-udat_setDefaultContext(UDateFormat* fmt,
-                       UDateFormatContextType type, UDateFormatContextValue value,
-                       UErrorCode* status)
+udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status)
 {
     verifyIsSimpleDateFormat(fmt, status);
     if (U_FAILURE(*status)) {
         return;
     }
-    ((SimpleDateFormat*)fmt)->setDefaultContext(type, value, *status);
+    ((SimpleDateFormat*)fmt)->setContext(value, *status);
 }
 
-U_CAPI int32_t U_EXPORT2
-udat_getDefaultContext(UDateFormat* fmt,
-                       UDateFormatContextType type,
-                       UErrorCode* status)
+U_CAPI UDisplayContext U_EXPORT2
+udat_getContext(UDateFormat* fmt, UDisplayContextType type, UErrorCode* status)
 {
     verifyIsSimpleDateFormat(fmt, status);
     if (U_FAILURE(*status)) {
-        return 0;
+        return (UDisplayContext)0;
     }
-    return ((SimpleDateFormat*)fmt)->getDefaultContext(type, *status);
+    return ((SimpleDateFormat*)fmt)->getContext(type, *status);
 }