ICU 60.2 60.2

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

- File List
- Globals

reldatefmt.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *****************************************************************************
5 * Copyright (C) 2014-2016, International Business Machines Corporation and
6 * others.
7 * All Rights Reserved.
8 *****************************************************************************
9 *
10 * File RELDATEFMT.H
11 *****************************************************************************
12 */
13
14 #ifndef __RELDATEFMT_H
15 #define __RELDATEFMT_H
16
17 #include "unicode/utypes.h"
18 #include "unicode/uobject.h"
19 #include "unicode/udisplaycontext.h"
20 #include "unicode/ureldatefmt.h"
21 #include "unicode/locid.h"
22
28 #if !UCONFIG_NO_FORMATTING
29
35 typedef enum UDateRelativeUnit {
36
41 UDAT_RELATIVE_SECONDS,
42
47 UDAT_RELATIVE_MINUTES,
48
53 UDAT_RELATIVE_HOURS,
54
59 UDAT_RELATIVE_DAYS,
60
65 UDAT_RELATIVE_WEEKS,
66
71 UDAT_RELATIVE_MONTHS,
72
77 UDAT_RELATIVE_YEARS,
78
79 #ifndef U_HIDE_DEPRECATED_API
80
84 UDAT_RELATIVE_UNIT_COUNT
85 #endif // U_HIDE_DEPRECATED_API
86 } UDateRelativeUnit;
87
92 typedef enum UDateAbsoluteUnit {
93
94 // Days of week have to remain together and in order from Sunday to
95 // Saturday.
100 UDAT_ABSOLUTE_SUNDAY,
101
106 UDAT_ABSOLUTE_MONDAY,
107
112 UDAT_ABSOLUTE_TUESDAY,
113
118 UDAT_ABSOLUTE_WEDNESDAY,
119
124 UDAT_ABSOLUTE_THURSDAY,
125
130 UDAT_ABSOLUTE_FRIDAY,
131
136 UDAT_ABSOLUTE_SATURDAY,
137
142 UDAT_ABSOLUTE_DAY,
143
148 UDAT_ABSOLUTE_WEEK,
149
154 UDAT_ABSOLUTE_MONTH,
155
160 UDAT_ABSOLUTE_YEAR,
161
166 UDAT_ABSOLUTE_NOW,
167
168 #ifndef U_HIDE_DEPRECATED_API
169
173 UDAT_ABSOLUTE_UNIT_COUNT
174 #endif // U_HIDE_DEPRECATED_API
175 } UDateAbsoluteUnit;
176
182 typedef enum UDateDirection {
183
188 UDAT_DIRECTION_LAST_2,
189
194 UDAT_DIRECTION_LAST,
195
200 UDAT_DIRECTION_THIS,
201
206 UDAT_DIRECTION_NEXT,
207
212 UDAT_DIRECTION_NEXT_2,
213
218 UDAT_DIRECTION_PLAIN,
219
220 #ifndef U_HIDE_DEPRECATED_API
221
225 UDAT_DIRECTION_COUNT
226 #endif // U_HIDE_DEPRECATED_API
227 } UDateDirection;
228
229 #if !UCONFIG_NO_BREAK_ITERATION
230
231 U_NAMESPACE_BEGIN
232
233 class BreakIterator;
234 class RelativeDateTimeCacheData;
235 class SharedNumberFormat;
236 class SharedPluralRules;
237 class SharedBreakIterator;
238 class NumberFormat;
239 class UnicodeString;
240
309 class U_I18N_API RelativeDateTimeFormatter : public UObject {
310 public:
311
316 RelativeDateTimeFormatter(UErrorCode& status);
317
322 RelativeDateTimeFormatter(const Locale& locale, UErrorCode& status);
323
334 RelativeDateTimeFormatter(
335 const Locale& locale, NumberFormat *nfToAdopt, UErrorCode& status);
336
352 RelativeDateTimeFormatter(
353 const Locale& locale,
354 NumberFormat *nfToAdopt,
355 UDateRelativeDateTimeFormatterStyle style,
356 UDisplayContext capitalizationContext,
357 UErrorCode& status);
358
363 RelativeDateTimeFormatter(const RelativeDateTimeFormatter& other);
364
369 RelativeDateTimeFormatter& operator=(
370 const RelativeDateTimeFormatter& other);
371
376 virtual ~RelativeDateTimeFormatter();
377
393 UnicodeString& format(
394 double quantity,
395 UDateDirection direction,
396 UDateRelativeUnit unit,
397 UnicodeString& appendTo,
398 UErrorCode& status) const;
399
412 UnicodeString& format(
413 UDateDirection direction,
414 UDateAbsoluteUnit unit,
415 UnicodeString& appendTo,
416 UErrorCode& status) const;
417
435 UnicodeString& formatNumeric(
436 double offset,
437 URelativeDateTimeUnit unit,
438 UnicodeString& appendTo,
439 UErrorCode& status) const;
440
458 UnicodeString& format(
459 double offset,
460 URelativeDateTimeUnit unit,
461 UnicodeString& appendTo,
462 UErrorCode& status) const;
463
476 UnicodeString& combineDateAndTime(
477 const UnicodeString& relativeDateString,
478 const UnicodeString& timeString,
479 UnicodeString& appendTo,
480 UErrorCode& status) const;
481
487 const NumberFormat& getNumberFormat() const;
488
494 UDisplayContext getCapitalizationContext() const;
495
501 UDateRelativeDateTimeFormatterStyle getFormatStyle() const;
502
503 private:
504 const RelativeDateTimeCacheData* fCache;
505 const SharedNumberFormat *fNumberFormat;
506 const SharedPluralRules *fPluralRules;
507 UDateRelativeDateTimeFormatterStyle fStyle;
508 UDisplayContext fContext;
509 const SharedBreakIterator *fOptBreakIterator;
510 Locale fLocale;
511 void init(
512 NumberFormat *nfToAdopt,
513 BreakIterator *brkIter,
514 UErrorCode &status);
515 void adjustForContext(UnicodeString &) const;
516 };
517
518 U_NAMESPACE_END
519
520 #endif /* !UCONFIG_NO_BREAK_ITERATION */
521 #endif /* !UCONFIG_NO_FORMATTING */
522 #endif /* __RELDATEFMT_H */
UDAT_ABSOLUTE_DAY
Day.
Definition: reldatefmt.h:142
UDAT_RELATIVE_MINUTES
Minutes.
Definition: reldatefmt.h:47
UDAT_ABSOLUTE_UNIT_COUNT
One more than the highest normal UDateAbsoluteUnit value.
Definition: reldatefmt.h:173
URelativeDateTimeUnit
URelativeDateTimeUnit
Represents the unit for formatting a relative date.
Definition: ureldatefmt.h:77
UDAT_ABSOLUTE_THURSDAY
Thursday.
Definition: reldatefmt.h:124
UDAT_DIRECTION_NEXT_2
Two after.
Definition: reldatefmt.h:212
icu::NumberFormat
Abstract base class for all number formats.
Definition: numfmt.h:174
UDisplayContext
UDisplayContext
Display context settings.
Definition: udisplaycontext.h:64
UDAT_RELATIVE_WEEKS
Weeks.
Definition: reldatefmt.h:65
UDAT_ABSOLUTE_MONDAY
Monday.
Definition: reldatefmt.h:106
UDAT_ABSOLUTE_FRIDAY
Friday.
Definition: reldatefmt.h:130
UDAT_RELATIVE_YEARS
Years.
Definition: reldatefmt.h:77
udisplaycontext.h
C API: Display context types (enum values)
UDAT_ABSOLUTE_SUNDAY
Sunday.
Definition: reldatefmt.h:100
UDAT_DIRECTION_LAST_2
Two before.
Definition: reldatefmt.h:188
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:360
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
ureldatefmt.h
C API: URelativeDateTimeFormatter, relative date formatting of unit + numeric offset.
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:102
UDAT_RELATIVE_DAYS
Days.
Definition: reldatefmt.h:59
UDateRelativeDateTimeFormatterStyle
UDateRelativeDateTimeFormatterStyle
The formatting style.
Definition: ureldatefmt.h:44
UDateDirection
UDateDirection
Represents a direction for an absolute unit e.g "Next Tuesday" or "Last Tuesday". ...
Definition: reldatefmt.h:182
UDAT_DIRECTION_PLAIN
Plain, which means the absence of a qualifier.
Definition: reldatefmt.h:218
icu::RelativeDateTimeFormatter
Formats simple relative dates.
Definition: reldatefmt.h:309
uobject.h
C++ API: Common ICU base class UObject.
UDAT_ABSOLUTE_TUESDAY
Tuesday.
Definition: reldatefmt.h:112
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
UDAT_ABSOLUTE_WEEK
Week.
Definition: reldatefmt.h:148
UDAT_DIRECTION_COUNT
One more than the highest normal UDateDirection value.
Definition: reldatefmt.h:225
UDateAbsoluteUnit
UDateAbsoluteUnit
Represents an absolute unit.
Definition: reldatefmt.h:92
UDAT_ABSOLUTE_YEAR
Year.
Definition: reldatefmt.h:160
UDAT_ABSOLUTE_SATURDAY
Saturday.
Definition: reldatefmt.h:136
locid.h
C++ API: Locale ID object.
UDAT_ABSOLUTE_NOW
Now.
Definition: reldatefmt.h:166
UDAT_DIRECTION_THIS
This.
Definition: reldatefmt.h:200
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UDAT_RELATIVE_HOURS
Hours.
Definition: reldatefmt.h:53
UDAT_ABSOLUTE_WEDNESDAY
Wednesday.
Definition: reldatefmt.h:118
UDAT_RELATIVE_SECONDS
Seconds.
Definition: reldatefmt.h:41
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:286
UDAT_RELATIVE_MONTHS
Months.
Definition: reldatefmt.h:71
UDAT_RELATIVE_UNIT_COUNT
One more than the highest normal UDateRelativeUnit value.
Definition: reldatefmt.h:84
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UDAT_ABSOLUTE_MONTH
Month.
Definition: reldatefmt.h:154
UDateRelativeUnit
UDateRelativeUnit
Represents the unit for formatting a relative date.
Definition: reldatefmt.h:35
UDAT_DIRECTION_LAST
Last.
Definition: reldatefmt.h:194
UDAT_DIRECTION_NEXT
Next.
Definition: reldatefmt.h:206
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188