+ case UDAT_STANDALONE_NARROW_MONTHS:
+ DateFormatSymbolsSingleSetter::setStandaloneNarrowMonth(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_WEEKDAYS:
+ DateFormatSymbolsSingleSetter::setWeekday(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_SHORT_WEEKDAYS:
+ 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;
+
+ case UDAT_STANDALONE_WEEKDAYS:
+ DateFormatSymbolsSingleSetter::setStandaloneWeekday(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_STANDALONE_SHORT_WEEKDAYS:
+ 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;
+
+ case UDAT_QUARTERS:
+ DateFormatSymbolsSingleSetter::setQuarter(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_SHORT_QUARTERS:
+ DateFormatSymbolsSingleSetter::setShortQuarter(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_STANDALONE_QUARTERS:
+ DateFormatSymbolsSingleSetter::setStandaloneQuarter(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_STANDALONE_SHORT_QUARTERS:
+ DateFormatSymbolsSingleSetter::setStandaloneShortQuarter(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_CYCLIC_YEARS_ABBREVIATED:
+ DateFormatSymbolsSingleSetter::setShortYearNames(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_ZODIAC_NAMES_ABBREVIATED:
+ DateFormatSymbolsSingleSetter::setShortZodiacNames(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_AM_PMS:
+ DateFormatSymbolsSingleSetter::setAmPm(syms, index, value, valueLength, *status);
+ break;
+
+ case UDAT_LOCALIZED_CHARS:
+ DateFormatSymbolsSingleSetter::setLocalPatternChars(syms, value, valueLength, *status);
+ break;
+
+ default:
+ *status = U_UNSUPPORTED_ERROR;
+ break;
+
+ }
+}
+
+U_CAPI const char* U_EXPORT2
+udat_getLocaleByType(const UDateFormat *fmt,
+ ULocDataLocaleType type,
+ UErrorCode* status)
+{
+ if (fmt == NULL) {
+ if (U_SUCCESS(*status)) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+ return NULL;
+ }
+ return ((Format*)fmt)->getLocaleID(type, *status);
+}
+
+U_CAPI void U_EXPORT2
+udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status)
+{
+ if (U_FAILURE(*status)) {
+ return;
+ }
+ ((DateFormat*)fmt)->setContext(value, *status);
+ return;
+}
+
+U_CAPI UDisplayContext U_EXPORT2
+udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status)
+{
+ if (U_FAILURE(*status)) {
+ return (UDisplayContext)0;
+ }
+ return ((const DateFormat*)fmt)->getContext(type, *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 familure or the fmt is NULL.
+ */
+static void verifyIsRelativeDateFormat(const UDateFormat* fmt, UErrorCode *status) {
+ if(U_SUCCESS(*status) &&
+ dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))==NULL) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+}
+
+
+U_CAPI int32_t U_EXPORT2
+udat_toPatternRelativeDate(const UDateFormat *fmt,
+ UChar *result,
+ int32_t resultLength,
+ UErrorCode *status)
+{
+ verifyIsRelativeDateFormat(fmt, status);
+ if(U_FAILURE(*status)) {
+ return -1;
+ }
+ if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ return -1;
+ }
+
+ UnicodeString datePattern;
+ if (result != NULL) {
+ // NULL destination for pure preflighting: empty dummy string
+ // otherwise, alias the destination buffer
+ datePattern.setTo(result, 0, resultLength);
+ }
+ ((RelativeDateFormat*)fmt)->toPatternDate(datePattern, *status);
+ return datePattern.extract(result, resultLength, *status);
+}
+
+U_CAPI int32_t U_EXPORT2
+udat_toPatternRelativeTime(const UDateFormat *fmt,
+ UChar *result,
+ int32_t resultLength,
+ UErrorCode *status)
+{
+ verifyIsRelativeDateFormat(fmt, status);
+ if(U_FAILURE(*status)) {
+ return -1;
+ }
+ if (result == NULL ? resultLength != 0 : resultLength < 0) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ return -1;
+ }
+
+ UnicodeString timePattern;
+ if (result != NULL) {
+ // NULL destination for pure preflighting: empty dummy string
+ // otherwise, alias the destination buffer
+ timePattern.setTo(result, 0, resultLength);
+ }
+ ((RelativeDateFormat*)fmt)->toPatternTime(timePattern, *status);
+ return timePattern.extract(result, resultLength, *status);
+}
+
+U_CAPI void U_EXPORT2
+udat_applyPatternRelative(UDateFormat *format,
+ const UChar *datePattern,
+ int32_t datePatternLength,
+ const UChar *timePattern,
+ int32_t timePatternLength,
+ UErrorCode *status)
+{
+ verifyIsRelativeDateFormat(format, status);
+ if(U_FAILURE(*status)) return;
+ const UnicodeString datePat((UBool)(datePatternLength == -1), datePattern, datePatternLength);
+ const UnicodeString timePat((UBool)(timePatternLength == -1), timePattern, timePatternLength);
+ ((RelativeDateFormat*)format)->applyPatterns(datePat, timePat, *status);