X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/57a6839dcb3bba09e8228b822b290604668416fe..4f1e1a09ce4daed860e35d359ce2fceccb0764e8:/icuSources/i18n/unicode/datefmt.h diff --git a/icuSources/i18n/unicode/datefmt.h b/icuSources/i18n/unicode/datefmt.h index ce967a5d..5ecf5923 100644 --- a/icuSources/i18n/unicode/datefmt.h +++ b/icuSources/i18n/unicode/datefmt.h @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************** - * Copyright (C) 1997-2014, International Business Machines + * Copyright (C) 1997-2016, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * @@ -36,13 +38,15 @@ * \brief C++ API: Abstract class for converting dates. */ +#if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN class TimeZone; class DateTimePatternGenerator; // explicit template instantiation. see digitlst.h -#if defined (_MSC_VER) +// (When building DLLs for Windows this is required.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN template class U_I18N_API EnumSet; @@ -571,6 +575,77 @@ public: EStyle timeStyle = kDefault, const Locale& aLocale = Locale::getDefault()); +#ifndef U_HIDE_INTERNAL_API + /** + * Returns the best pattern given a skeleton and locale. + * @param locale the locale + * @param skeleton the skeleton + * @param status ICU error returned here + * @return the best pattern. + * @internal For ICU use only. + */ + static UnicodeString getBestPattern( + const Locale &locale, + const UnicodeString &skeleton, + UErrorCode &status); +#endif /* U_HIDE_INTERNAL_API */ + + /** + * Creates a date/time formatter for the given skeleton and + * default locale. + * + * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can + * be in any order, and this method uses the locale to + * map the skeleton to a pattern that includes locale + * specific separators with the fields in the appropriate + * order for that locale. + * @param status Any error returned here. + * @return A date/time formatter which the caller owns. + * @stable ICU 55 + */ + static DateFormat* U_EXPORT2 createInstanceForSkeleton( + const UnicodeString& skeleton, + UErrorCode &status); + + /** + * Creates a date/time formatter for the given skeleton and locale. + * + * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can + * be in any order, and this method uses the locale to + * map the skeleton to a pattern that includes locale + * specific separators with the fields in the appropriate + * order for that locale. + * @param locale The given locale. + * @param status Any error returned here. + * @return A date/time formatter which the caller owns. + * @stable ICU 55 + */ + static DateFormat* U_EXPORT2 createInstanceForSkeleton( + const UnicodeString& skeleton, + const Locale &locale, + UErrorCode &status); + + /** + * Creates a date/time formatter for the given skeleton and locale. + * + * @param calendarToAdopt the calendar returned DateFormat is to use. + * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can + * be in any order, and this method uses the locale to + * map the skeleton to a pattern that includes locale + * specific separators with the fields in the appropriate + * order for that locale. + * @param locale The given locale. + * @param status Any error returned here. + * @return A date/time formatter which the caller owns. + * @stable ICU 55 + */ + static DateFormat* U_EXPORT2 createInstanceForSkeleton( + Calendar *calendarToAdopt, + const UnicodeString& skeleton, + const Locale &locale, + UErrorCode &status); + + /** * Gets the set of locales for which DateFormats are installed. * @param count Filled in with the number of locales in the list that is returned. @@ -610,15 +685,13 @@ public: virtual void setLenient(UBool lenient); - /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */ /** * Returns whether date/time parsing in the encapsulated Calendar object processing is lenient. - * @draft ICU 53 + * @stable ICU 53 */ virtual UBool isCalendarLenient(void) const; - /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */ /** * Specifies whether encapsulated Calendar date/time parsing is to be lenient. With * lenient parsing, the parser may use heuristics to interpret inputs that @@ -626,7 +699,7 @@ public: * inputs must match this object's format more closely. * @param lenient when true, parsing is lenient * @see com.ibm.icu.util.Calendar#setLenient - * @draft ICU 53 + * @stable ICU 53 */ virtual void setCalendarLenient(UBool lenient); @@ -707,7 +780,6 @@ public: */ virtual void setTimeZone(const TimeZone& zone); - /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */ /** * Set a particular UDisplayContext value in the formatter, such as * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. @@ -715,11 +787,10 @@ public: * @param status Input/output status. If at entry this indicates a failure * status, the function will do nothing; otherwise this will be * updated with any new status from the function. - * @draft ICU 53 + * @stable ICU 53 */ virtual void setContext(UDisplayContext value, UErrorCode& status); - /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */ /** * Get the formatter's UDisplayContext value for the specified UDisplayContextType, * such as UDISPCTX_TYPE_CAPITALIZATION. @@ -728,11 +799,10 @@ public: * status, the function will do nothing; otherwise this will be * updated with any new status from the function. * @return The UDisplayContextValue for the specified type. - * @draft ICU 53 + * @stable ICU 53 */ virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const; - /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */ /** * Sets an boolean attribute on this DateFormat. * May return U_UNSUPPORTED_ERROR if this instance does not support @@ -741,14 +811,13 @@ public: * @param newvalue new value * @param status the error type * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) ) - * @draft ICU 53 + * @stable ICU 53 */ virtual DateFormat& U_EXPORT2 setBooleanAttribute(UDateFormatBooleanAttribute attr, UBool newvalue, UErrorCode &status); - /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */ /** * Returns a boolean from this DateFormat * May return U_UNSUPPORTED_ERROR if this instance does not support @@ -756,7 +825,7 @@ public: * @param attr the attribute to set * @param status the error type * @return the attribute value. Undefined if there is an error. - * @draft ICU 53 + * @stable ICU 53 */ virtual UBool U_EXPORT2 getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &status) const; @@ -799,6 +868,7 @@ protected: private: + /** * Gets the date/time formatter with the given formatting styles for the * given locale. @@ -817,6 +887,7 @@ private: UDisplayContext fCapitalizationContext; + friend class DateFmtKeyByStyle; public: #ifndef U_HIDE_OBSOLETE_API @@ -876,6 +947,7 @@ public: }; U_NAMESPACE_END +#endif // U_SHOW_CPLUSPLUS_API #endif /* #if !UCONFIG_NO_FORMATTING */