ICU 56.1: reldatefmt.h Source File

ICU 56.1 56.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

reldatefmt.h
Go to the documentation of this file.
1 /*
2 *****************************************************************************
3 * Copyright (C) 2014-2015, International Business Machines Corporation and
4 * others.
5 * All Rights Reserved.
6 *****************************************************************************
7 *
8 * File RELDATEFMT.H
9 *****************************************************************************
10 */
11
12 #ifndef __RELDATEFMT_H
13 #define __RELDATEFMT_H
14
15 #include "unicode/utypes.h"
16 #include "unicode/uobject.h"
17 #include "unicode/udisplaycontext.h"
18 #include "unicode/locid.h"
19
25 #if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION
26
31 typedef enum UDateRelativeDateTimeFormatterStyle {
36 UDAT_STYLE_LONG,
37
42 UDAT_STYLE_SHORT,
43
48 UDAT_STYLE_NARROW,
49
54 UDAT_STYLE_COUNT
55 } UDateRelativeDateTimeFormatterStyle;
56
62 typedef enum UDateRelativeUnit {
63
68 UDAT_RELATIVE_SECONDS,
69
74 UDAT_RELATIVE_MINUTES,
75
80 UDAT_RELATIVE_HOURS,
81
86 UDAT_RELATIVE_DAYS,
87
92 UDAT_RELATIVE_WEEKS,
93
98 UDAT_RELATIVE_MONTHS,
99
104 UDAT_RELATIVE_YEARS,
105
110 UDAT_RELATIVE_UNIT_COUNT
111 } UDateRelativeUnit;
112
117 typedef enum UDateAbsoluteUnit {
118
119 // Days of week have to remain together and in order from Sunday to
120 // Saturday.
125 UDAT_ABSOLUTE_SUNDAY,
126
131 UDAT_ABSOLUTE_MONDAY,
132
137 UDAT_ABSOLUTE_TUESDAY,
138
143 UDAT_ABSOLUTE_WEDNESDAY,
144
149 UDAT_ABSOLUTE_THURSDAY,
150
155 UDAT_ABSOLUTE_FRIDAY,
156
161 UDAT_ABSOLUTE_SATURDAY,
162
167 UDAT_ABSOLUTE_DAY,
168
173 UDAT_ABSOLUTE_WEEK,
174
179 UDAT_ABSOLUTE_MONTH,
180
185 UDAT_ABSOLUTE_YEAR,
186
191 UDAT_ABSOLUTE_NOW,
192
197 UDAT_ABSOLUTE_UNIT_COUNT
198 } UDateAbsoluteUnit;
199
205 typedef enum UDateDirection {
206
211 UDAT_DIRECTION_LAST_2,
212
217 UDAT_DIRECTION_LAST,
218
223 UDAT_DIRECTION_THIS,
224
229 UDAT_DIRECTION_NEXT,
230
235 UDAT_DIRECTION_NEXT_2,
236
241 UDAT_DIRECTION_PLAIN,
242
247 UDAT_DIRECTION_COUNT
248 } UDateDirection;
249
250
251 U_NAMESPACE_BEGIN
252
253 class RelativeDateTimeCacheData;
254 class SharedNumberFormat;
255 class SharedPluralRules;
256 class SharedBreakIterator;
257 class NumberFormat;
258 class UnicodeString;
259
328 class U_I18N_API RelativeDateTimeFormatter : public UObject {
329 public:
330
335 RelativeDateTimeFormatter(UErrorCode& status);
336
341 RelativeDateTimeFormatter(const Locale& locale, UErrorCode& status);
342
353 RelativeDateTimeFormatter(
354 const Locale& locale, NumberFormat *nfToAdopt, UErrorCode& status);
355
371 RelativeDateTimeFormatter(
372 const Locale& locale,
373 NumberFormat *nfToAdopt,
374 UDateRelativeDateTimeFormatterStyle style,
375 UDisplayContext capitalizationContext,
376 UErrorCode& status);
377
382 RelativeDateTimeFormatter(const RelativeDateTimeFormatter& other);
383
388 RelativeDateTimeFormatter& operator=(
389 const RelativeDateTimeFormatter& other);
390
395 virtual ~RelativeDateTimeFormatter();
396
412 UnicodeString& format(
413 double quantity,
414 UDateDirection direction,
415 UDateRelativeUnit unit,
416 UnicodeString& appendTo,
417 UErrorCode& status) const;
418
431 UnicodeString& format(
432 UDateDirection direction,
433 UDateAbsoluteUnit unit,
434 UnicodeString& appendTo,
435 UErrorCode& status) const;
436
449 UnicodeString& combineDateAndTime(
450 const UnicodeString& relativeDateString,
451 const UnicodeString& timeString,
452 UnicodeString& appendTo,
453 UErrorCode& status) const;
454
460 const NumberFormat& getNumberFormat() const;
461
467 UDisplayContext getCapitalizationContext() const;
468
474 UDateRelativeDateTimeFormatterStyle getFormatStyle() const;
475
476 private:
477 const RelativeDateTimeCacheData* fCache;
478 const SharedNumberFormat *fNumberFormat;
479 const SharedPluralRules *fPluralRules;
480 UDateRelativeDateTimeFormatterStyle fStyle;
481 UDisplayContext fContext;
482 const SharedBreakIterator *fOptBreakIterator;
483 Locale fLocale;
484 void init(
485 NumberFormat *nfToAdopt,
486 BreakIterator *brkIter,
487 UErrorCode &status);
488 void adjustForContext(UnicodeString &) const;
489 };
490
491 U_NAMESPACE_END
492
493 #endif /* !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION*/
494 #endif
UDAT_ABSOLUTE_DAY
Day.
Definition: reldatefmt.h:167
UDAT_RELATIVE_MINUTES
Minutes.
Definition: reldatefmt.h:74
UDAT_ABSOLUTE_UNIT_COUNT
Count of items in this enum.
Definition: reldatefmt.h:197
UDAT_ABSOLUTE_THURSDAY
Thursday.
Definition: reldatefmt.h:149
UDAT_DIRECTION_NEXT_2
Two after.
Definition: reldatefmt.h:235
icu::NumberFormat
Abstract base class for all number formats.
Definition: numfmt.h:172
UDAT_STYLE_LONG
Everything spelled out.
Definition: reldatefmt.h:36
UDateRelativeDateTimeFormatterStyle
UDateRelativeDateTimeFormatterStyle
The formatting style.
Definition: reldatefmt.h:31
UDisplayContext
UDisplayContext
Display context settings.
Definition: udisplaycontext.h:56
UDAT_RELATIVE_WEEKS
Weeks.
Definition: reldatefmt.h:92
UDAT_ABSOLUTE_MONDAY
Monday.
Definition: reldatefmt.h:131
UDAT_ABSOLUTE_FRIDAY
Friday.
Definition: reldatefmt.h:155
UDAT_RELATIVE_YEARS
Years.
Definition: reldatefmt.h:104
UDAT_STYLE_SHORT
Abbreviations used when possible.
Definition: reldatefmt.h:42
udisplaycontext.h
C API: Display context types (enum values)
UDAT_ABSOLUTE_SUNDAY
Sunday.
Definition: reldatefmt.h:125
UDAT_DIRECTION_LAST_2
Two before.
Definition: reldatefmt.h:211
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:100
UDAT_RELATIVE_DAYS
Days.
Definition: reldatefmt.h:86
UDateDirection
UDateDirection
Represents a direction for an absolute unit e.g "Next Tuesday" or "Last Tuesday". ...
Definition: reldatefmt.h:205
UDAT_DIRECTION_PLAIN
Plain, which means the absence of a qualifier.
Definition: reldatefmt.h:241
icu::RelativeDateTimeFormatter
Formats simple relative dates.
Definition: reldatefmt.h:328
UDAT_STYLE_COUNT
The number of styles.
Definition: reldatefmt.h:54
uobject.h
C++ API: Common ICU base class UObject.
UDAT_ABSOLUTE_TUESDAY
Tuesday.
Definition: reldatefmt.h:137
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UDAT_STYLE_NARROW
Use the shortest possible form.
Definition: reldatefmt.h:48
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
UDAT_ABSOLUTE_WEEK
Week.
Definition: reldatefmt.h:173
UDAT_DIRECTION_COUNT
Count of items in this enum.
Definition: reldatefmt.h:247
UDateAbsoluteUnit
UDateAbsoluteUnit
Represents an absolute unit.
Definition: reldatefmt.h:117
UDAT_ABSOLUTE_YEAR
Year.
Definition: reldatefmt.h:185
UDAT_ABSOLUTE_SATURDAY
Saturday.
Definition: reldatefmt.h:161
locid.h
C++ API: Locale ID object.
UDAT_ABSOLUTE_NOW
Now.
Definition: reldatefmt.h:191
UDAT_DIRECTION_THIS
This.
Definition: reldatefmt.h:223
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UDAT_RELATIVE_HOURS
Hours.
Definition: reldatefmt.h:80
UDAT_ABSOLUTE_WEDNESDAY
Wednesday.
Definition: reldatefmt.h:143
UDAT_RELATIVE_SECONDS
Seconds.
Definition: reldatefmt.h:68
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
UDAT_RELATIVE_MONTHS
Months.
Definition: reldatefmt.h:98
UDAT_RELATIVE_UNIT_COUNT
Count of items in this enum.
Definition: reldatefmt.h:110
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UDAT_ABSOLUTE_MONTH
Month.
Definition: reldatefmt.h:179
UDateRelativeUnit
UDateRelativeUnit
Represents the unit for formatting a relative date.
Definition: reldatefmt.h:62
UDAT_DIRECTION_LAST
Last.
Definition: reldatefmt.h:217
UDAT_DIRECTION_NEXT
Next.
Definition: reldatefmt.h:229
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185