chromium/third_party/icu/source/i18n/udat.cpp

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*   Copyright (C) 1996-2015, International Business Machines
*   Corporation and others.  All Rights Reserved.
*******************************************************************************
*/

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/udat.h"

#include "unicode/uloc.h"
#include "unicode/datefmt.h"
#include "unicode/timezone.h"
#include "unicode/smpdtfmt.h"
#include "unicode/fieldpos.h"
#include "unicode/parsepos.h"
#include "unicode/calendar.h"
#include "unicode/numfmt.h"
#include "unicode/dtfmtsym.h"
#include "unicode/ustring.h"
#include "unicode/udisplaycontext.h"
#include "unicode/ufieldpositer.h"
#include "cpputils.h"
#include "reldtfmt.h"
#include "umutex.h"

U_NAMESPACE_USE

/**
 * Verify that fmt is a SimpleDateFormat. Invalid error if not.
 * @param fmt the UDateFormat, definitely a DateFormat, maybe something else
 * @param status error code, will be set to failure if there is a failure or the fmt is nullptr.
 */
static void verifyIsSimpleDateFormat(const UDateFormat* fmt, UErrorCode *status) {}

// This mirrors the correspondence between the
// SimpleDateFormat::fgPatternIndexToDateFormatField and
// SimpleDateFormat::fgPatternIndexToCalendarField arrays.
static UCalendarDateFields gDateFieldMapping[] =;

U_CAPI UCalendarDateFields U_EXPORT2
udat_toCalendarDateField(UDateFormatField field) UPRV_NO_SANITIZE_UNDEFINED {}

/* For now- one opener. */
static UDateFormatOpener gOpener =;

U_CAPI void U_EXPORT2
udat_registerOpener(UDateFormatOpener opener, UErrorCode *status)
{}

U_CAPI UDateFormatOpener U_EXPORT2
udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status)
{}



U_CAPI UDateFormat* U_EXPORT2
udat_open(UDateFormatStyle  timeStyle,
          UDateFormatStyle  dateStyle,
          const char        *locale,
          const char16_t    *tzID,
          int32_t           tzIDLength,
          const char16_t    *pattern,
          int32_t           patternLength,
          UErrorCode        *status)
{}


U_CAPI void U_EXPORT2
udat_close(UDateFormat* format)
{}

U_CAPI UDateFormat* U_EXPORT2
udat_clone(const UDateFormat *fmt,
       UErrorCode *status)
{}

U_CAPI int32_t U_EXPORT2
udat_format(    const    UDateFormat*    format,
        UDate           dateToFormat,
        char16_t*          result,
        int32_t         resultLength,
        UFieldPosition* position,
        UErrorCode*     status)
{}

U_CAPI int32_t U_EXPORT2
udat_formatCalendar(const UDateFormat*  format,
        UCalendar*      calendar,
        char16_t*          result,
        int32_t         resultLength,
        UFieldPosition* position,
        UErrorCode*     status)
{}

U_CAPI int32_t U_EXPORT2
udat_formatForFields(    const    UDateFormat*    format,
        UDate           dateToFormat,
        char16_t*          result,
        int32_t         resultLength,
        UFieldPositionIterator* fpositer,
        UErrorCode*     status)
{}

U_CAPI int32_t U_EXPORT2
udat_formatCalendarForFields(const UDateFormat*  format,
        UCalendar*      calendar,
        char16_t*          result,
        int32_t         resultLength,
        UFieldPositionIterator* fpositer,
        UErrorCode*     status)
{}

U_CAPI UDate U_EXPORT2
udat_parse(    const    UDateFormat*        format,
        const    char16_t*          text,
        int32_t         textLength,
        int32_t         *parsePos,
        UErrorCode      *status)
{}

U_CAPI void U_EXPORT2
udat_parseCalendar(const    UDateFormat*    format,
                            UCalendar*      calendar,
                   const    char16_t*          text,
                            int32_t         textLength,
                            int32_t         *parsePos,
                            UErrorCode      *status)
{}

U_CAPI UBool U_EXPORT2
udat_isLenient(const UDateFormat* fmt)
{}

U_CAPI void U_EXPORT2
udat_setLenient(    UDateFormat*    fmt,
            UBool          isLenient)
{}

U_CAPI UBool U_EXPORT2
udat_getBooleanAttribute(const UDateFormat* fmt, 
                         UDateFormatBooleanAttribute attr, 
                         UErrorCode* status)
{}

U_CAPI void U_EXPORT2
udat_setBooleanAttribute(UDateFormat *fmt, 
                         UDateFormatBooleanAttribute attr, 
                         UBool newValue, 
                         UErrorCode* status)
{}

U_CAPI const UCalendar* U_EXPORT2
udat_getCalendar(const UDateFormat* fmt)
{}

U_CAPI void U_EXPORT2
udat_setCalendar(UDateFormat*    fmt,
                 const   UCalendar*      calendarToSet)
{}

U_CAPI const UNumberFormat* U_EXPORT2 
udat_getNumberFormatForField(const UDateFormat* fmt, char16_t field)
{}

U_CAPI const UNumberFormat* U_EXPORT2
udat_getNumberFormat(const UDateFormat* fmt)
{}

U_CAPI void U_EXPORT2 
udat_adoptNumberFormatForFields(           UDateFormat*    fmt,
                                    const  char16_t*          fields,
                                           UNumberFormat*  numberFormatToSet,
                                           UErrorCode*     status)
{}

U_CAPI void U_EXPORT2
udat_setNumberFormat(UDateFormat*    fmt,
                     const   UNumberFormat*  numberFormatToSet)
{}

U_CAPI void U_EXPORT2
udat_adoptNumberFormat(      UDateFormat*    fmt,
                             UNumberFormat*  numberFormatToAdopt)
{}

U_CAPI const char* U_EXPORT2
udat_getAvailable(int32_t index)
{}

U_CAPI int32_t U_EXPORT2
udat_countAvailable()
{}

U_CAPI UDate U_EXPORT2
udat_get2DigitYearStart(    const   UDateFormat     *fmt,
                        UErrorCode      *status)
{}

U_CAPI void U_EXPORT2
udat_set2DigitYearStart(    UDateFormat     *fmt,
                        UDate           d,
                        UErrorCode      *status)
{}

U_CAPI int32_t U_EXPORT2
udat_toPattern(    const   UDateFormat     *fmt,
        UBool          localized,
        char16_t        *result,
        int32_t         resultLength,
        UErrorCode      *status)
{}

// TODO: should this take an UErrorCode?
// A: Yes. Of course.
U_CAPI void U_EXPORT2
udat_applyPattern(  UDateFormat     *format,
                    UBool          localized,
                    const   char16_t        *pattern,
                    int32_t         patternLength)
{}

U_CAPI int32_t U_EXPORT2
udat_getSymbols(const   UDateFormat     *fmt,
                UDateFormatSymbolType   type,
                int32_t                 index,
                char16_t                *result,
                int32_t                 resultLength,
                UErrorCode              *status)
{}

// TODO: also needs an errorCode.
U_CAPI int32_t U_EXPORT2
udat_countSymbols(    const    UDateFormat                *fmt,
            UDateFormatSymbolType    type)
{}

U_NAMESPACE_BEGIN

/*
 * This DateFormatSymbolsSingleSetter class is a friend of DateFormatSymbols
 * solely for the purpose of avoiding to clone the array of strings
 * just to modify one of them and then setting all of them back.
 * For example, the old code looked like this:
 *  case UDAT_MONTHS:
 *    res = syms->getMonths(count);
 *    array = new UnicodeString[count];
 *    if(array == 0) {
 *      *status = U_MEMORY_ALLOCATION_ERROR;
 *      return;
 *    }
 *    uprv_arrayCopy(res, array, count);
 *    if(index < count)
 *      array[index] = val;
 *    syms->setMonths(array, count);
 *    break;
 *
 * Even worse, the old code actually cloned the entire DateFormatSymbols object,
 * cloned one value array, changed one value, and then made the SimpleDateFormat
 * replace its DateFormatSymbols object with the new one.
 *
 * markus 2002-oct-14
 */
class DateFormatSymbolsSingleSetter /* not : public UObject because all methods are static */ {};

U_NAMESPACE_END

U_CAPI void U_EXPORT2
udat_setSymbols(    UDateFormat             *format,
            UDateFormatSymbolType   type,
            int32_t                 index,
            char16_t                *value,
            int32_t                 valueLength,
            UErrorCode              *status)
{}

U_CAPI const char* U_EXPORT2
udat_getLocaleByType(const UDateFormat *fmt,
                     ULocDataLocaleType type,
                     UErrorCode* status)
{}

U_CAPI void U_EXPORT2
udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status)
{}

U_CAPI UDisplayContext U_EXPORT2
udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status)
{}


/**
 * Verify that fmt is a RelativeDateFormat. Invalid error if not.
 * @param fmt the UDateFormat, definitely a DateFormat, maybe something else
 * @param status error code, will be set to failure if there is a failure or the fmt is nullptr.
 */
static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *status) {}


U_CAPI int32_t U_EXPORT2 
udat_toPatternRelativeDate(const UDateFormat *fmt,
                           char16_t          *result,
                           int32_t           resultLength,
                           UErrorCode        *status)
{}

U_CAPI int32_t U_EXPORT2 
udat_toPatternRelativeTime(const UDateFormat *fmt,
                           char16_t          *result,
                           int32_t           resultLength,
                           UErrorCode        *status)
{}

U_CAPI void U_EXPORT2 
udat_applyPatternRelative(UDateFormat *format,
                          const char16_t *datePattern,
                          int32_t     datePatternLength,
                          const char16_t *timePattern,
                          int32_t     timePatternLength,
                          UErrorCode  *status)
{}

#endif /* #if !UCONFIG_NO_FORMATTING */