00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef URELDATEFMT_H
00011 #define URELDATEFMT_H
00012
00013 #include "unicode/utypes.h"
00014
00015 #if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION
00016
00017 #include "unicode/unum.h"
00018 #include "unicode/udisplaycontext.h"
00019 #include "unicode/localpointer.h"
00020 #include "unicode/uformattedvalue.h"
00021
00045 typedef enum UDateRelativeDateTimeFormatterStyle {
00050 UDAT_STYLE_LONG,
00051
00056 UDAT_STYLE_SHORT,
00057
00062 UDAT_STYLE_NARROW,
00063
00064 #ifndef U_HIDE_DEPRECATED_API
00065
00069 UDAT_STYLE_COUNT
00070 #endif
00071 } UDateRelativeDateTimeFormatterStyle;
00072
00078 typedef enum URelativeDateTimeUnit {
00084 UDAT_REL_UNIT_YEAR,
00090 UDAT_REL_UNIT_QUARTER,
00096 UDAT_REL_UNIT_MONTH,
00102 UDAT_REL_UNIT_WEEK,
00108 UDAT_REL_UNIT_DAY,
00114 UDAT_REL_UNIT_HOUR,
00120 UDAT_REL_UNIT_MINUTE,
00126 UDAT_REL_UNIT_SECOND,
00132 UDAT_REL_UNIT_SUNDAY,
00138 UDAT_REL_UNIT_MONDAY,
00144 UDAT_REL_UNIT_TUESDAY,
00150 UDAT_REL_UNIT_WEDNESDAY,
00156 UDAT_REL_UNIT_THURSDAY,
00162 UDAT_REL_UNIT_FRIDAY,
00168 UDAT_REL_UNIT_SATURDAY,
00169 #ifndef U_HIDE_DEPRECATED_API
00170
00174 UDAT_REL_UNIT_COUNT
00175 #endif
00176 } URelativeDateTimeUnit;
00177
00183 typedef enum URelativeDateTimeFormatterField {
00188 UDAT_REL_LITERAL_FIELD,
00193 UDAT_REL_NUMERIC_FIELD,
00194 } URelativeDateTimeFormatterField;
00195
00196
00201 struct URelativeDateTimeFormatter;
00202 typedef struct URelativeDateTimeFormatter URelativeDateTimeFormatter;
00237 U_STABLE URelativeDateTimeFormatter* U_EXPORT2
00238 ureldatefmt_open( const char* locale,
00239 UNumberFormat* nfToAdopt,
00240 UDateRelativeDateTimeFormatterStyle width,
00241 UDisplayContext capitalizationContext,
00242 UErrorCode* status );
00243
00250 U_STABLE void U_EXPORT2
00251 ureldatefmt_close(URelativeDateTimeFormatter *reldatefmt);
00252
00253 struct UFormattedRelativeDateTime;
00258 typedef struct UFormattedRelativeDateTime UFormattedRelativeDateTime;
00259
00269 U_STABLE UFormattedRelativeDateTime* U_EXPORT2
00270 ureldatefmt_openResult(UErrorCode* ec);
00271
00286 U_STABLE const UFormattedValue* U_EXPORT2
00287 ureldatefmt_resultAsValue(const UFormattedRelativeDateTime* ufrdt, UErrorCode* ec);
00288
00295 U_STABLE void U_EXPORT2
00296 ureldatefmt_closeResult(UFormattedRelativeDateTime* ufrdt);
00297
00298
00299 #if U_SHOW_CPLUSPLUS_API
00300
00301 U_NAMESPACE_BEGIN
00302
00312 U_DEFINE_LOCAL_OPEN_POINTER(LocalURelativeDateTimeFormatterPointer, URelativeDateTimeFormatter, ureldatefmt_close);
00313
00323 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedRelativeDateTimePointer, UFormattedRelativeDateTime, ureldatefmt_closeResult);
00324
00325 U_NAMESPACE_END
00326
00327 #endif
00328
00357 U_STABLE int32_t U_EXPORT2
00358 ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
00359 double offset,
00360 URelativeDateTimeUnit unit,
00361 UChar* result,
00362 int32_t resultCapacity,
00363 UErrorCode* status);
00364
00388 U_STABLE void U_EXPORT2
00389 ureldatefmt_formatNumericToResult(
00390 const URelativeDateTimeFormatter* reldatefmt,
00391 double offset,
00392 URelativeDateTimeUnit unit,
00393 UFormattedRelativeDateTime* result,
00394 UErrorCode* status);
00395
00424 U_STABLE int32_t U_EXPORT2
00425 ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
00426 double offset,
00427 URelativeDateTimeUnit unit,
00428 UChar* result,
00429 int32_t resultCapacity,
00430 UErrorCode* status);
00431
00458 U_STABLE void U_EXPORT2
00459 ureldatefmt_formatToResult(
00460 const URelativeDateTimeFormatter* reldatefmt,
00461 double offset,
00462 URelativeDateTimeUnit unit,
00463 UFormattedRelativeDateTime* result,
00464 UErrorCode* status);
00465
00495 U_STABLE int32_t U_EXPORT2
00496 ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt,
00497 const UChar * relativeDateString,
00498 int32_t relativeDateStringLen,
00499 const UChar * timeString,
00500 int32_t timeStringLen,
00501 UChar* result,
00502 int32_t resultCapacity,
00503 UErrorCode* status );
00504
00505 #endif
00506
00507 #endif