ICU-6855 Add internal RelativeDateFormat toPattern/applyPattern functions

X-SVN-Rev: 25831
This commit is contained in:
Peter Edberg 2009-04-18 08:15:46 +00:00
parent bf6746fb3b
commit 991253ead3
2 changed files with 93 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007, International Business Machines Corporation and *
* Copyright (C) 2007-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -179,9 +179,44 @@ public:
*/
virtual UDate parse( const UnicodeString& text,
UErrorCode& status) const;
/**
* Return a single pattern string generated by combining the patterns for the
* date and time formatters associated with this object.
* @param result Output param to receive the pattern.
* @return A reference to 'result'.
* @internal ICU 4.2 technology preview
*/
virtual UnicodeString& toPattern(UnicodeString& result, UErrorCode& status) const;
/**
* Get the date pattern for the the date formatter associated with this object.
* @param result Output param to receive the date pattern.
* @return A reference to 'result'.
* @internal ICU 4.2 technology preview
*/
virtual UnicodeString& toPatternDate(UnicodeString& result, UErrorCode& status) const;
/**
* Get the time pattern for the the time formatter associated with this object.
* @param result Output param to receive the time pattern.
* @return A reference to 'result'.
* @internal ICU 4.2 technology preview
*/
virtual UnicodeString& toPatternTime(UnicodeString& result, UErrorCode& status) const;
/**
* Apply the given unlocalized date & time pattern strings to this relative date format.
* (i.e., after this call, this formatter will format dates and times according to
* the new patterns)
*
* @param datePattern The date pattern to be applied.
* @param timePattern The time pattern to be applied.
* @internal ICU 4.2 technology preview
*/
virtual void applyPatterns(const UnicodeString& datePattern, const UnicodeString& timePattern, UErrorCode &status);
private:
DateFormat *fDateFormat; // the held date format
DateFormat *fTimeFormat; // the held time format

View file

@ -903,6 +903,60 @@ udat_getLocaleByType(const UDateFormat *fmt,
ULocDataLocaleType type,
UErrorCode* status);
/**
* Extract the date pattern from a UDateFormat set for relative date formatting.
* The pattern will follow the pattern syntax rules.
* @param fmt The formatter to query.
* @param result A pointer to a buffer to receive the pattern.
* @param resultLength The maximum size of result.
* @param status A pointer to a UErrorCode to receive any errors
* @return The total buffer size needed; if greater than resultLength, the output was truncated.
* @see udat_applyPatternRelative
* @internal ICU 4.2 technology preview
*/
U_INTERNAL int32_t U_EXPORT2
udat_toPatternRelativeDate(const UDateFormat *fmt,
UChar *result,
int32_t resultLength,
UErrorCode *status);
/**
* Extract the time pattern from a UDateFormat set for relative date formatting.
* The pattern will follow the pattern syntax rules.
* @param fmt The formatter to query.
* @param result A pointer to a buffer to receive the pattern.
* @param resultLength The maximum size of result.
* @param status A pointer to a UErrorCode to receive any errors
* @return The total buffer size needed; if greater than resultLength, the output was truncated.
* @see udat_applyPatternRelative
* @internal ICU 4.2 technology preview
*/
U_INTERNAL int32_t U_EXPORT2
udat_toPatternRelativeTime(const UDateFormat *fmt,
UChar *result,
int32_t resultLength,
UErrorCode *status);
/**
* Set the date & time patterns used by a UDateFormat set for relative date formatting.
* The patterns should follow the pattern syntax rules.
* @param format The formatter to set.
* @param datePattern The new date pattern
* @param datePatternLength The length of datePattern, or -1 if null-terminated.
* @param timePattern The new time pattern
* @param timePatternLength The length of timePattern, or -1 if null-terminated.
* @param status A pointer to a UErrorCode to receive any errors
* @see udat_toPatternRelativeDate, udat_toPatternRelativeTime
* @internal ICU 4.2 technology preview
*/
U_INTERNAL void U_EXPORT2
udat_applyPatternRelative(UDateFormat *format,
const UChar *datePattern,
int32_t datePatternLength,
const UChar *timePattern,
int32_t timePatternLength,
UErrorCode *status);
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif