X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/46f4442e9a5a4f3b98b7c1083586332f6a8a99a4..51004dcb01e06fef634b61be77ed73dd61cb6db9:/icuSources/i18n/reldtfmt.h diff --git a/icuSources/i18n/reldtfmt.h b/icuSources/i18n/reldtfmt.h index 97573241..1206ea3a 100644 --- a/icuSources/i18n/reldtfmt.h +++ b/icuSources/i18n/reldtfmt.h @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2007-2009, International Business Machines Corporation and * +* Copyright (C) 2007-2012, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -11,29 +11,32 @@ #include "unicode/utypes.h" /** - * \file + * \file * \brief C++ API: Format and parse relative dates and times. */ - + #if !UCONFIG_NO_FORMATTING #include "unicode/datefmt.h" +#include "unicode/smpdtfmt.h" U_NAMESPACE_BEGIN // forward declarations +class DateFormatSymbols; class MessageFormat; // internal structure used for caching strings struct URelativeString; /** - * This class is normally accessed using the kRelative or k...Relative values of EStyle as parameters to DateFormat::createDateInstance. - * - * Example: + * This class is normally accessed using the kRelative or k...Relative values of EStyle as + * parameters to DateFormat::createDateInstance. + * + * Example: * DateFormat *fullrelative = DateFormat::createDateInstance(DateFormat::kFullRelative, loc); - * - * @draft ICU 3.8 + * + * @internal ICU 3.8 */ class RelativeDateFormat : public DateFormat { @@ -43,19 +46,19 @@ public: // overrides /** * Copy constructor. - * @draft ICU 3.8 + * @internal ICU 3.8 */ RelativeDateFormat(const RelativeDateFormat&); /** * Assignment operator. - * @draft ICU 3.8 + * @internal ICU 3.8 */ RelativeDateFormat& operator=(const RelativeDateFormat&); /** * Destructor. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual ~RelativeDateFormat(); @@ -63,7 +66,7 @@ public: * Clone this Format object polymorphically. The caller owns the result and * should delete it when done. * @return A copy of the object. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual Format* clone(void) const; @@ -72,10 +75,13 @@ public: * of different subclasses are considered unequal. * @param other the object to be compared with. * @return true if the given Format objects are semantically equal. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual UBool operator==(const Format& other) const; + + using DateFormat::format; + /** * Format a date or time, which is the standard millis since 24:00 GMT, Jan * 1, 1970. Overrides DateFormat pure virtual method. @@ -90,7 +96,7 @@ public: * @param pos The formatting position. On input: an alignment field, * if desired. On output: the offsets of the alignment field. * @return Reference to 'appendTo' parameter. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual UnicodeString& format( Calendar& cal, UnicodeString& appendTo, @@ -108,7 +114,7 @@ public: * On output: the offsets of the alignment field. * @param status Output param filled with success/failure status. * @return Reference to 'appendTo' parameter. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual UnicodeString& format(const Formattable& obj, UnicodeString& appendTo, @@ -133,11 +139,11 @@ public: * output, the position at which parsing terminated, or the * start position if the parse failed. * @return A valid UDate if the input could be parsed. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual void parse( const UnicodeString& text, Calendar& cal, - ParsePosition& pos) const; + ParsePosition& pos) const; /** * Parse a date/time string starting at the given parse position. For @@ -156,7 +162,7 @@ public: * output, the position at which parsing terminated, or the * start position if the parse failed. * @return A valid UDate if the input could be parsed. - * @draft ICU 3.8 + * @internal ICU 3.8 */ UDate parse( const UnicodeString& text, ParsePosition& pos) const; @@ -175,7 +181,7 @@ public: * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with * an error value if there was a parse error. * @return A valid UDate if the input could be parsed. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual UDate parse( const UnicodeString& text, UErrorCode& status) const; @@ -216,50 +222,60 @@ public: */ virtual void applyPatterns(const UnicodeString& datePattern, const UnicodeString& timePattern, UErrorCode &status); + /** + * Gets the date/time formatting symbols (this is an object carrying + * the various strings and other symbols used in formatting: e.g., month + * names and abbreviations, time zone names, AM/PM strings, etc.) + * @return a copy of the date-time formatting data associated + * with this date-time formatter. + * @internal ICU 4.8 + */ + virtual const DateFormatSymbols* getDateFormatSymbols(void) const; + private: - DateFormat *fDateFormat; // the held date format - DateFormat *fTimeFormat; // the held time format - MessageFormat *fCombinedFormat; // the {0} {1} format. - + SimpleDateFormat *fDateTimeFormatter; + UnicodeString fDatePattern; + UnicodeString fTimePattern; + MessageFormat *fCombinedFormat; // the {0} {1} format. + UDateFormatStyle fDateStyle; - UDateFormatStyle fTimeStyle; Locale fLocale; - + int32_t fDayMin; // day id of lowest # int32_t fDayMax; // day id of highest # int32_t fDatesLen; // Length of array URelativeString *fDates; // array of strings - - + + /** * Get the string at a specific offset. * @param day day offset ( -1, 0, 1, etc.. ) - * @param len on output, length of string. + * @param len on output, length of string. * @return the string, or NULL if none at that location. */ const UChar *getStringForDay(int32_t day, int32_t &len, UErrorCode &status) const; - - /** + + /** * Load the Date string array */ void loadDates(UErrorCode &status); - + /** * @return the number of days in "until-now" */ static int32_t dayDifference(Calendar &until, UErrorCode &status); - + /** * initializes fCalendar from parameters. Returns fCalendar as a convenience. * @param adoptZone Zone to be adopted, or NULL for TimeZone::createDefault(). * @param locale Locale of the calendar * @param status Error code * @return the newly constructed fCalendar - * @draft ICU 3.8 + * @internal ICU 3.8 */ Calendar* initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status); - + public: /** * Return the class ID for this class. This is useful only for comparing to @@ -270,7 +286,7 @@ public: * . erived::getStaticClassID()) ... * * @return The class ID for all objects of this class. - * @draft ICU 3.8 + * @internal ICU 3.8 */ U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); @@ -283,7 +299,7 @@ public: * @return The class ID for this object. All objects of a * given class have the same class ID. Objects of * other classes have different class IDs. - * @draft ICU 3.8 + * @internal ICU 3.8 */ virtual UClassID getDynamicClassID(void) const; };