ureldatefmt.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
* Copyright (C) 2016, International Business Machines
* Corporation and others. All Rights Reserved.
*****************************************************************************************
*/
#ifndef URELDATEFMT_H
#define URELDATEFMT_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/unum.h"
#include "unicode/udisplaycontext.h"
#include "unicode/uformattedvalue.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
typedef enum UDateRelativeDateTimeFormatterStyle {
UDAT_STYLE_LONG,
UDAT_STYLE_SHORT,
UDAT_STYLE_NARROW,
#ifndef U_HIDE_DEPRECATED_API
UDAT_STYLE_COUNT
#endif /* U_HIDE_DEPRECATED_API */
} UDateRelativeDateTimeFormatterStyle;
typedef enum URelativeDateTimeUnit {
UDAT_REL_UNIT_YEAR,
UDAT_REL_UNIT_QUARTER,
UDAT_REL_UNIT_MONTH,
UDAT_REL_UNIT_WEEK,
UDAT_REL_UNIT_DAY,
UDAT_REL_UNIT_HOUR,
UDAT_REL_UNIT_MINUTE,
UDAT_REL_UNIT_SECOND,
UDAT_REL_UNIT_SUNDAY,
UDAT_REL_UNIT_MONDAY,
UDAT_REL_UNIT_TUESDAY,
UDAT_REL_UNIT_WEDNESDAY,
UDAT_REL_UNIT_THURSDAY,
UDAT_REL_UNIT_FRIDAY,
UDAT_REL_UNIT_SATURDAY,
#ifndef U_HIDE_DEPRECATED_API
UDAT_REL_UNIT_COUNT
#endif /* U_HIDE_DEPRECATED_API */
} URelativeDateTimeUnit;
typedef enum URelativeDateTimeFormatterField {
UDAT_REL_LITERAL_FIELD,
UDAT_REL_NUMERIC_FIELD,
} URelativeDateTimeFormatterField;
struct URelativeDateTimeFormatter;
typedef struct URelativeDateTimeFormatter URelativeDateTimeFormatter;
U_CAPI URelativeDateTimeFormatter* U_EXPORT2
ureldatefmt_open( const char* locale,
UNumberFormat* nfToAdopt,
UDateRelativeDateTimeFormatterStyle width,
UDisplayContext capitalizationContext,
UErrorCode* status );
U_CAPI void U_EXPORT2
ureldatefmt_close(URelativeDateTimeFormatter *reldatefmt);
struct UFormattedRelativeDateTime;
typedef struct UFormattedRelativeDateTime UFormattedRelativeDateTime;
U_CAPI UFormattedRelativeDateTime* U_EXPORT2
ureldatefmt_openResult(UErrorCode* ec);
U_CAPI const UFormattedValue* U_EXPORT2
ureldatefmt_resultAsValue(const UFormattedRelativeDateTime* ufrdt, UErrorCode* ec);
U_CAPI void U_EXPORT2
ureldatefmt_closeResult(UFormattedRelativeDateTime* ufrdt);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalURelativeDateTimeFormatterPointer, URelativeDateTimeFormatter, ureldatefmt_close);
U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedRelativeDateTimePointer, UFormattedRelativeDateTime, ureldatefmt_closeResult);
U_NAMESPACE_END
#endif
U_CAPI int32_t U_EXPORT2
ureldatefmt_formatNumeric( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
UChar* result,
int32_t resultCapacity,
UErrorCode* status);
U_CAPI void U_EXPORT2
ureldatefmt_formatNumericToResult(
const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
UFormattedRelativeDateTime* result,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
ureldatefmt_format( const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
UChar* result,
int32_t resultCapacity,
UErrorCode* status);
U_CAPI void U_EXPORT2
ureldatefmt_formatToResult(
const URelativeDateTimeFormatter* reldatefmt,
double offset,
URelativeDateTimeUnit unit,
UFormattedRelativeDateTime* result,
UErrorCode* status);
U_CAPI int32_t U_EXPORT2
ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt,
const UChar * relativeDateString,
int32_t relativeDateStringLen,
const UChar * timeString,
int32_t timeStringLen,
UChar* result,
int32_t resultCapacity,
UErrorCode* status );
#endif /* !UCONFIG_NO_FORMATTING */
#endif
LocalUFormattedRelativeDateTimePointer
"Smart pointer" class, closes a UFormattedRelativeDateTime via ureldatefmt_closeResult().
Definition: ureldatefmt.h:315
LocalURelativeDateTimeFormatterPointer
"Smart pointer" class, closes a URelativeDateTimeFormatter via ureldatefmt_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
udisplaycontext.h
C API: Display context types (enum values)
UDisplayContext
UDisplayContext
Display context settings.
Definition: udisplaycontext.h:64
uformattedvalue.h
C API: Abstract operations for localized strings.
UFormattedValue
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: uformattedvalue.h:368
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:386
unum.h
C API: Compatibility APIs for number formatting.
UNumberFormat
void * UNumberFormat
A number formatter.
Definition: unum.h:145
ureldatefmt_formatNumeric
U_CAPI int32_t ureldatefmt_formatNumeric(const URelativeDateTimeFormatter *reldatefmt, double offset, URelativeDateTimeUnit unit, UChar *result, int32_t resultCapacity, UErrorCode *status)
Format a combination of URelativeDateTimeUnit and numeric offset using a numeric style,...
ureldatefmt_close
U_CAPI void ureldatefmt_close(URelativeDateTimeFormatter *reldatefmt)
Close a URelativeDateTimeFormatter object.
ureldatefmt_format
U_CAPI int32_t ureldatefmt_format(const URelativeDateTimeFormatter *reldatefmt, double offset, URelativeDateTimeUnit unit, UChar *result, int32_t resultCapacity, UErrorCode *status)
Format a combination of URelativeDateTimeUnit and numeric offset using a text style if possible,...
ureldatefmt_resultAsValue
U_CAPI const UFormattedValue * ureldatefmt_resultAsValue(const UFormattedRelativeDateTime *ufrdt, UErrorCode *ec)
Returns a representation of a UFormattedRelativeDateTime as a UFormattedValue, which can be subsequen...
ureldatefmt_formatToResult
U_CAPI void ureldatefmt_formatToResult(const URelativeDateTimeFormatter *reldatefmt, double offset, URelativeDateTimeUnit unit, UFormattedRelativeDateTime *result, UErrorCode *status)
Format a combination of URelativeDateTimeUnit and numeric offset using a text style if possible,...
ureldatefmt_formatNumericToResult
U_CAPI void ureldatefmt_formatNumericToResult(const URelativeDateTimeFormatter *reldatefmt, double offset, URelativeDateTimeUnit unit, UFormattedRelativeDateTime *result, UErrorCode *status)
Format a combination of URelativeDateTimeUnit and numeric offset using a numeric style,...
UDateRelativeDateTimeFormatterStyle
UDateRelativeDateTimeFormatterStyle
The formatting style.
Definition: ureldatefmt.h:48
UDAT_STYLE_COUNT
@ UDAT_STYLE_COUNT
One more than the highest normal UDateRelativeDateTimeFormatterStyle value.
Definition: ureldatefmt.h:72
UDAT_STYLE_LONG
@ UDAT_STYLE_LONG
Everything spelled out.
Definition: ureldatefmt.h:53
UDAT_STYLE_NARROW
@ UDAT_STYLE_NARROW
Use the shortest possible form.
Definition: ureldatefmt.h:65
UDAT_STYLE_SHORT
@ UDAT_STYLE_SHORT
Abbreviations used when possible.
Definition: ureldatefmt.h:59
ureldatefmt_combineDateAndTime
U_CAPI int32_t ureldatefmt_combineDateAndTime(const URelativeDateTimeFormatter *reldatefmt, const UChar *relativeDateString, int32_t relativeDateStringLen, const UChar *timeString, int32_t timeStringLen, UChar *result, int32_t resultCapacity, UErrorCode *status)
Combines a relative date string and a time string in this object's locale.
ureldatefmt_openResult
U_CAPI UFormattedRelativeDateTime * ureldatefmt_openResult(UErrorCode *ec)
Creates an object to hold the result of a URelativeDateTimeFormatter operation.
ureldatefmt_open
U_CAPI URelativeDateTimeFormatter * ureldatefmt_open(const char *locale, UNumberFormat *nfToAdopt, UDateRelativeDateTimeFormatterStyle width, UDisplayContext capitalizationContext, UErrorCode *status)
Open a new URelativeDateTimeFormatter object for a given locale using the specified width and capital...
URelativeDateTimeUnit
URelativeDateTimeUnit
Represents the unit for formatting a relative date.
Definition: ureldatefmt.h:81
UDAT_REL_UNIT_SATURDAY
@ UDAT_REL_UNIT_SATURDAY
Specifies that relative unit is Saturday, e.g.
Definition: ureldatefmt.h:171
UDAT_REL_UNIT_WEEK
@ UDAT_REL_UNIT_WEEK
Specifies that relative unit is week, e.g.
Definition: ureldatefmt.h:105
UDAT_REL_UNIT_SECOND
@ UDAT_REL_UNIT_SECOND
Specifies that relative unit is second, e.g.
Definition: ureldatefmt.h:129
UDAT_REL_UNIT_FRIDAY
@ UDAT_REL_UNIT_FRIDAY
Specifies that relative unit is Friday, e.g.
Definition: ureldatefmt.h:165
UDAT_REL_UNIT_DAY
@ UDAT_REL_UNIT_DAY
Specifies that relative unit is day, e.g.
Definition: ureldatefmt.h:111
UDAT_REL_UNIT_COUNT
@ UDAT_REL_UNIT_COUNT
One more than the highest normal URelativeDateTimeUnit value.
Definition: ureldatefmt.h:177
UDAT_REL_UNIT_MONTH
@ UDAT_REL_UNIT_MONTH
Specifies that relative unit is month, e.g.
Definition: ureldatefmt.h:99
UDAT_REL_UNIT_SUNDAY
@ UDAT_REL_UNIT_SUNDAY
Specifies that relative unit is Sunday, e.g.
Definition: ureldatefmt.h:135
UDAT_REL_UNIT_WEDNESDAY
@ UDAT_REL_UNIT_WEDNESDAY
Specifies that relative unit is Wednesday, e.g.
Definition: ureldatefmt.h:153
UDAT_REL_UNIT_QUARTER
@ UDAT_REL_UNIT_QUARTER
Specifies that relative unit is quarter, e.g.
Definition: ureldatefmt.h:93
UDAT_REL_UNIT_HOUR
@ UDAT_REL_UNIT_HOUR
Specifies that relative unit is hour, e.g.
Definition: ureldatefmt.h:117
UDAT_REL_UNIT_MINUTE
@ UDAT_REL_UNIT_MINUTE
Specifies that relative unit is minute, e.g.
Definition: ureldatefmt.h:123
UDAT_REL_UNIT_TUESDAY
@ UDAT_REL_UNIT_TUESDAY
Specifies that relative unit is Tuesday, e.g.
Definition: ureldatefmt.h:147
UDAT_REL_UNIT_THURSDAY
@ UDAT_REL_UNIT_THURSDAY
Specifies that relative unit is Thursday, e.g.
Definition: ureldatefmt.h:159
UDAT_REL_UNIT_MONDAY
@ UDAT_REL_UNIT_MONDAY
Specifies that relative unit is Monday, e.g.
Definition: ureldatefmt.h:141
UDAT_REL_UNIT_YEAR
@ UDAT_REL_UNIT_YEAR
Specifies that relative unit is year, e.g.
Definition: ureldatefmt.h:87
URelativeDateTimeFormatter
struct URelativeDateTimeFormatter URelativeDateTimeFormatter
C typedef for struct URelativeDateTimeFormatter.
Definition: ureldatefmt.h:205
ureldatefmt_closeResult
U_CAPI void ureldatefmt_closeResult(UFormattedRelativeDateTime *ufrdt)
Releases the UFormattedRelativeDateTime created by ureldatefmt_openResult.
UFormattedRelativeDateTime
struct UFormattedRelativeDateTime UFormattedRelativeDateTime
Opaque struct to contain the results of a URelativeDateTimeFormatter operation.
Definition: ureldatefmt.h:261
URelativeDateTimeFormatterField
URelativeDateTimeFormatterField
FieldPosition and UFieldPosition selectors for format fields defined by RelativeDateTimeFormatter.
Definition: ureldatefmt.h:186
UDAT_REL_LITERAL_FIELD
@ UDAT_REL_LITERAL_FIELD
Represents a literal text string, like "tomorrow" or "days ago".
Definition: ureldatefmt.h:191
UDAT_REL_NUMERIC_FIELD
@ UDAT_REL_NUMERIC_FIELD
Represents a number quantity, like "3" in "3 days ago".
Definition: ureldatefmt.h:196
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415