ICU 49.1.1  49.1.1
udat.h
Go to the documentation of this file.
00001 /*
00002  *******************************************************************************
00003  * Copyright (C) 1996-2012, International Business Machines
00004  * Corporation and others. All Rights Reserved.
00005  *******************************************************************************
00006 */
00007 
00008 #ifndef UDAT_H
00009 #define UDAT_H
00010 
00011 #include "unicode/utypes.h"
00012 
00013 #if !UCONFIG_NO_FORMATTING
00014 
00015 #include "unicode/localpointer.h"
00016 #include "unicode/ucal.h"
00017 #include "unicode/unum.h"
00139 typedef void* UDateFormat;
00140 
00144 typedef enum UDateFormatStyle {
00146     UDAT_FULL,
00148     UDAT_LONG,
00150     UDAT_MEDIUM,
00152     UDAT_SHORT,
00154     UDAT_DEFAULT = UDAT_MEDIUM,
00155 
00157     UDAT_RELATIVE = (1 << 7),
00158     
00159     UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
00160         
00161     UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
00162     
00163     UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
00164     
00165     UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
00166     
00167     
00169     UDAT_NONE = -1,
00171     UDAT_IGNORE = -2
00172 
00173 } UDateFormatStyle;
00174 
00175 /* Cannot use #ifndef U_HIDE_DRAFT_API for UDateFormatContextType and UDateFormatContextValue
00176  * since a SimpleDateFormat virtual method & data member depends on them */
00180 typedef enum UDateFormatContextType {
00186     UDAT_CAPITALIZATION = 1
00187 } UDateFormatContextType;
00188 
00192 typedef enum UDateFormatContextValue {
00201     UDAT_CONTEXT_UNKNOWN = 0,
00202 #if !UCONFIG_NO_BREAK_ITERATION
00203 
00209     UDAT_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE = 1,
00215     UDAT_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE = 2,
00221     UDAT_CAPITALIZATION_FOR_UI_LIST_OR_MENU = 3,
00228     UDAT_CAPITALIZATION_FOR_STANDALONE = 4
00229 #endif
00230 } UDateFormatContextValue;
00231 
00263 #define UDAT_MINUTE_SECOND              "ms"
00264 #define UDAT_HOUR24_MINUTE              "Hm"
00265 #define UDAT_HOUR24_MINUTE_SECOND       "Hms"      
00266 #define UDAT_HOUR_MINUTE_SECOND         "hms"
00267 #define UDAT_STANDALONE_MONTH           "LLLL"
00268 #define UDAT_ABBR_STANDALONE_MONTH      "LLL"
00269 #define UDAT_YEAR_QUARTER               "yQQQ"
00270 #define UDAT_YEAR_ABBR_QUARTER          "yQ"
00271 
00282 #define UDAT_HOUR_MINUTE                "hm"
00283 #define UDAT_YEAR                       "y"
00284 #define UDAT_DAY                        "d"
00285 #define UDAT_NUM_MONTH_WEEKDAY_DAY      "MEd"
00286 #define UDAT_YEAR_NUM_MONTH             "yM"              
00287 #define UDAT_NUM_MONTH_DAY              "Md"
00288 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
00289 #define UDAT_ABBR_MONTH_WEEKDAY_DAY     "MMMEd"
00290 #define UDAT_YEAR_MONTH                 "yMMMM"
00291 #define UDAT_YEAR_ABBR_MONTH            "yMMM"
00292 #define UDAT_MONTH_DAY                  "MMMMd"
00293 #define UDAT_ABBR_MONTH_DAY             "MMMd" 
00294 #define UDAT_MONTH_WEEKDAY_DAY          "MMMMEEEEd"
00295 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd" 
00296 #define UDAT_YEAR_MONTH_WEEKDAY_DAY     "yMMMMEEEEd"
00297 #define UDAT_YEAR_MONTH_DAY             "yMMMMd"
00298 #define UDAT_YEAR_ABBR_MONTH_DAY        "yMMMd"
00299 #define UDAT_YEAR_NUM_MONTH_DAY         "yMd"
00300 #define UDAT_NUM_MONTH                  "M"
00301 #define UDAT_ABBR_MONTH                 "MMM"
00302 #define UDAT_MONTH                      "MMMM"
00303 #define UDAT_HOUR_MINUTE_GENERIC_TZ     "hmv"
00304 #define UDAT_HOUR_MINUTE_TZ             "hmz"
00305 #define UDAT_HOUR                       "h"
00306 #define UDAT_HOUR_GENERIC_TZ            "hv"
00307 #define UDAT_HOUR_TZ                    "hz"
00308 
00317 typedef enum UDateFormatField {
00323     UDAT_ERA_FIELD = 0,
00324 
00330     UDAT_YEAR_FIELD = 1,
00331 
00337     UDAT_MONTH_FIELD = 2,
00338 
00344     UDAT_DATE_FIELD = 3,
00345 
00353     UDAT_HOUR_OF_DAY1_FIELD = 4,
00354 
00362     UDAT_HOUR_OF_DAY0_FIELD = 5,
00363 
00369     UDAT_MINUTE_FIELD = 6,
00370 
00376     UDAT_SECOND_FIELD = 7,
00377 
00383     UDAT_FRACTIONAL_SECOND_FIELD = 8,
00384 
00390     UDAT_DAY_OF_WEEK_FIELD = 9,
00391 
00397     UDAT_DAY_OF_YEAR_FIELD = 10,
00398 
00404     UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,
00405 
00411     UDAT_WEEK_OF_YEAR_FIELD = 12,
00412 
00418     UDAT_WEEK_OF_MONTH_FIELD = 13,
00419 
00425     UDAT_AM_PM_FIELD = 14,
00426 
00434     UDAT_HOUR1_FIELD = 15,
00435 
00443     UDAT_HOUR0_FIELD = 16,
00444 
00451     UDAT_TIMEZONE_FIELD = 17,
00452 
00458     UDAT_YEAR_WOY_FIELD = 18,
00459 
00465     UDAT_DOW_LOCAL_FIELD = 19,
00466 
00472     UDAT_EXTENDED_YEAR_FIELD = 20,
00473 
00479     UDAT_JULIAN_DAY_FIELD = 21,
00480 
00486     UDAT_MILLISECONDS_IN_DAY_FIELD = 22,
00487 
00494     UDAT_TIMEZONE_RFC_FIELD = 23,
00495 
00501     UDAT_TIMEZONE_GENERIC_FIELD = 24,
00508     UDAT_STANDALONE_DAY_FIELD = 25,
00509 
00516     UDAT_STANDALONE_MONTH_FIELD = 26,
00517 
00525     UDAT_QUARTER_FIELD = 27,
00526 
00534     UDAT_STANDALONE_QUARTER_FIELD = 28,
00535 
00541     UDAT_TIMEZONE_SPECIAL_FIELD = 29,
00542 
00550     UDAT_YEAR_NAME_FIELD = 30,
00551 
00560     UDAT_FIELD_COUNT = 31
00561 
00562 } UDateFormatField;
00563 
00564 
00573 U_STABLE UCalendarDateFields U_EXPORT2
00574 udat_toCalendarDateField(UDateFormatField field);
00575 
00576 
00602 U_STABLE UDateFormat* U_EXPORT2 
00603 udat_open(UDateFormatStyle  timeStyle,
00604           UDateFormatStyle  dateStyle,
00605           const char        *locale,
00606           const UChar       *tzID,
00607           int32_t           tzIDLength,
00608           const UChar       *pattern,
00609           int32_t           patternLength,
00610           UErrorCode        *status);
00611 
00612 
00619 U_STABLE void U_EXPORT2 
00620 udat_close(UDateFormat* format);
00621 
00622 #if U_SHOW_CPLUSPLUS_API
00623 
00624 U_NAMESPACE_BEGIN
00625 
00635 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);
00636 
00637 U_NAMESPACE_END
00638 
00639 #endif
00640 
00649 U_STABLE UDateFormat* U_EXPORT2 
00650 udat_clone(const UDateFormat *fmt,
00651        UErrorCode *status);
00652 
00671 U_STABLE int32_t U_EXPORT2 
00672 udat_format(    const    UDateFormat*    format,
00673                         UDate           dateToFormat,
00674                         UChar*          result,
00675                         int32_t         resultLength,
00676                         UFieldPosition* position,
00677                         UErrorCode*     status);
00678 
00704 U_STABLE UDate U_EXPORT2 
00705 udat_parse(const    UDateFormat*    format,
00706            const    UChar*          text,
00707                     int32_t         textLength,
00708                     int32_t         *parsePos,
00709                     UErrorCode      *status);
00710 
00732 U_STABLE void U_EXPORT2 
00733 udat_parseCalendar(const    UDateFormat*    format,
00734                             UCalendar*      calendar,
00735                    const    UChar*          text,
00736                             int32_t         textLength,
00737                             int32_t         *parsePos,
00738                             UErrorCode      *status);
00739 
00749 U_STABLE UBool U_EXPORT2 
00750 udat_isLenient(const UDateFormat* fmt);
00751 
00761 U_STABLE void U_EXPORT2 
00762 udat_setLenient(    UDateFormat*    fmt,
00763                     UBool          isLenient);
00764 
00774 U_STABLE const UCalendar* U_EXPORT2 
00775 udat_getCalendar(const UDateFormat* fmt);
00776 
00786 U_STABLE void U_EXPORT2 
00787 udat_setCalendar(            UDateFormat*    fmt,
00788                     const   UCalendar*      calendarToSet);
00789 
00799 U_STABLE const UNumberFormat* U_EXPORT2 
00800 udat_getNumberFormat(const UDateFormat* fmt);
00801 
00811 U_STABLE void U_EXPORT2 
00812 udat_setNumberFormat(            UDateFormat*    fmt,
00813                         const   UNumberFormat*  numberFormatToSet);
00814 
00824 U_STABLE const char* U_EXPORT2 
00825 udat_getAvailable(int32_t localeIndex);
00826 
00835 U_STABLE int32_t U_EXPORT2 
00836 udat_countAvailable(void);
00837 
00848 U_STABLE UDate U_EXPORT2 
00849 udat_get2DigitYearStart(    const   UDateFormat     *fmt,
00850                                     UErrorCode      *status);
00851 
00862 U_STABLE void U_EXPORT2 
00863 udat_set2DigitYearStart(    UDateFormat     *fmt,
00864                             UDate           d,
00865                             UErrorCode      *status);
00866 
00879 U_STABLE int32_t U_EXPORT2 
00880 udat_toPattern(    const   UDateFormat     *fmt,
00881                         UBool          localized,
00882                         UChar           *result,
00883                         int32_t         resultLength,
00884                         UErrorCode      *status);
00885 
00896 U_STABLE void U_EXPORT2 
00897 udat_applyPattern(            UDateFormat     *format,
00898                             UBool          localized,
00899                     const   UChar           *pattern,
00900                             int32_t         patternLength);
00901 
00906 typedef enum UDateFormatSymbolType {
00908     UDAT_ERAS,
00910     UDAT_MONTHS,
00912     UDAT_SHORT_MONTHS,
00914     UDAT_WEEKDAYS,
00916     UDAT_SHORT_WEEKDAYS,
00918     UDAT_AM_PMS,
00920     UDAT_LOCALIZED_CHARS,
00922     UDAT_ERA_NAMES,
00924     UDAT_NARROW_MONTHS,
00926     UDAT_NARROW_WEEKDAYS,
00928     UDAT_STANDALONE_MONTHS,
00929     UDAT_STANDALONE_SHORT_MONTHS,
00930     UDAT_STANDALONE_NARROW_MONTHS,
00932     UDAT_STANDALONE_WEEKDAYS,
00933     UDAT_STANDALONE_SHORT_WEEKDAYS,
00934     UDAT_STANDALONE_NARROW_WEEKDAYS,
00936     UDAT_QUARTERS,
00938     UDAT_SHORT_QUARTERS,
00940     UDAT_STANDALONE_QUARTERS,
00941     UDAT_STANDALONE_SHORT_QUARTERS
00942 
00943 } UDateFormatSymbolType;
00944 
00945 struct UDateFormatSymbols;
00950 typedef struct UDateFormatSymbols UDateFormatSymbols;
00951 
00968 U_STABLE int32_t U_EXPORT2 
00969 udat_getSymbols(const   UDateFormat             *fmt,
00970                         UDateFormatSymbolType   type,
00971                         int32_t                 symbolIndex,
00972                         UChar                   *result,
00973                         int32_t                 resultLength,
00974                         UErrorCode              *status);
00975 
00988 U_STABLE int32_t U_EXPORT2 
00989 udat_countSymbols(    const    UDateFormat                *fmt,
00990                             UDateFormatSymbolType    type);
00991 
01007 U_STABLE void U_EXPORT2 
01008 udat_setSymbols(    UDateFormat             *format,
01009                     UDateFormatSymbolType   type,
01010                     int32_t                 symbolIndex,
01011                     UChar                   *value,
01012                     int32_t                 valueLength,
01013                     UErrorCode              *status);
01014 
01024 U_STABLE const char* U_EXPORT2
01025 udat_getLocaleByType(const UDateFormat *fmt,
01026                      ULocDataLocaleType type,
01027                      UErrorCode* status); 
01028 
01029 #ifndef U_HIDE_DRAFT_API
01030 
01039 U_DRAFT void U_EXPORT2
01040 udat_setDefaultContext(UDateFormat* fmt,
01041                        UDateFormatContextType type, UDateFormatContextValue value,
01042                        UErrorCode* status);
01043 
01053 U_DRAFT int32_t U_EXPORT2
01054 udat_getDefaultContext(UDateFormat* fmt,
01055                        UDateFormatContextType type,
01056                        UErrorCode* status);
01057 #endif  /* U_HIDE_DRAFT_API */
01058 
01059 #ifndef U_HIDE_INTERNAL_API
01060 
01071 U_INTERNAL int32_t U_EXPORT2 
01072 udat_toPatternRelativeDate(const UDateFormat *fmt,
01073                            UChar             *result,
01074                            int32_t           resultLength,
01075                            UErrorCode        *status);
01076 
01088 U_INTERNAL int32_t U_EXPORT2 
01089 udat_toPatternRelativeTime(const UDateFormat *fmt,
01090                            UChar             *result,
01091                            int32_t           resultLength,
01092                            UErrorCode        *status);
01093 
01106 U_INTERNAL void U_EXPORT2 
01107 udat_applyPatternRelative(UDateFormat *format,
01108                           const UChar *datePattern,
01109                           int32_t     datePatternLength,
01110                           const UChar *timePattern,
01111                           int32_t     timePatternLength,
01112                           UErrorCode  *status);
01113 #endif  /* U_HIDE_INTERNAL_API */
01114 
01119 typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle  timeStyle,
01120                                                     UDateFormatStyle  dateStyle,
01121                                                     const char        *locale,
01122                                                     const UChar       *tzID,
01123                                                     int32_t           tzIDLength,
01124                                                     const UChar       *pattern,
01125                                                     int32_t           patternLength,
01126                                                     UErrorCode        *status);
01127 
01132 U_INTERNAL void U_EXPORT2
01133 udat_registerOpener(UDateFormatOpener opener, UErrorCode *status);
01134 
01139 U_INTERNAL UDateFormatOpener U_EXPORT2
01140 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);
01141 
01142 
01143 #endif /* #if !UCONFIG_NO_FORMATTING */
01144 
01145 #endif