ICU 55.1  55.1
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"
18 #include "unicode/locid.h"
19 
25 #if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION
26 
27 #ifndef U_HIDE_DRAFT_API
28 
34 
40 
46 
52 
59 
60 #endif /* U_HIDE_DRAFT_API */
61 
67 typedef enum UDateRelativeUnit {
68 
74 
80 
86 
92 
98 
104 
110 
117 
122 typedef enum UDateAbsoluteUnit {
123 
124  // Days of week have to remain together and in order from Sunday to
125  // Saturday.
131 
137 
143 
149 
155 
161 
167 
173 
179 
185 
191 
197 
204 
210 typedef enum UDateDirection {
211 
217 
223 
229 
235 
241 
247 
254 
255 
257 
258 class RelativeDateTimeCacheData;
259 class SharedNumberFormat;
260 class SharedPluralRules;
261 class SharedBreakIterator;
262 class NumberFormat;
263 class UnicodeString;
264 
334 public:
335 
341 
346  RelativeDateTimeFormatter(const Locale& locale, UErrorCode& status);
347 
359  const Locale& locale, NumberFormat *nfToAdopt, UErrorCode& status);
360 
361 #ifndef U_HIDE_DRAFT_API
362 
378  const Locale& locale,
379  NumberFormat *nfToAdopt,
381  UDisplayContext capitalizationContext,
382  UErrorCode& status);
383 #endif /* U_HIDE_DRAFT_API */
384 
390 
395  RelativeDateTimeFormatter& operator=(
396  const RelativeDateTimeFormatter& other);
397 
402  virtual ~RelativeDateTimeFormatter();
403 
419  UnicodeString& format(
420  double quantity,
421  UDateDirection direction,
422  UDateRelativeUnit unit,
423  UnicodeString& appendTo,
424  UErrorCode& status) const;
425 
438  UnicodeString& format(
439  UDateDirection direction,
440  UDateAbsoluteUnit unit,
441  UnicodeString& appendTo,
442  UErrorCode& status) const;
443 
456  UnicodeString& combineDateAndTime(
457  const UnicodeString& relativeDateString,
458  const UnicodeString& timeString,
459  UnicodeString& appendTo,
460  UErrorCode& status) const;
461 
467  const NumberFormat& getNumberFormat() const;
468 
469 #ifndef U_HIDE_DRAFT_API
470 
475  UDisplayContext getCapitalizationContext() const;
476 
482  UDateRelativeDateTimeFormatterStyle getFormatStyle() const;
483 #endif /* U_HIDE_DRAFT_API */
484 
485 private:
486  const RelativeDateTimeCacheData* fCache;
487  const SharedNumberFormat *fNumberFormat;
488  const SharedPluralRules *fPluralRules;
490  UDisplayContext fContext;
491  const SharedBreakIterator *fOptBreakIterator;
492  Locale fLocale;
493  void init(
494  NumberFormat *nfToAdopt,
495  BreakIterator *brkIter,
496  UErrorCode &status);
497  void adjustForContext(UnicodeString &) const;
498 };
499 
501 
502 #endif /* !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION*/
503 #endif
Count of items in this enum.
Definition: reldatefmt.h:202
Abstract base class for all number formats.
Definition: numfmt.h:172
Everything spelled out.
Definition: reldatefmt.h:39
UDateRelativeDateTimeFormatterStyle
The formatting style.
Definition: reldatefmt.h:33
UDisplayContext
Display context settings.
Abbreviations used when possible.
Definition: reldatefmt.h:45
C API: Display context types (enum values)
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:100
UDateDirection
Represents a direction for an absolute unit e.g "Next Tuesday" or "Last Tuesday". ...
Definition: reldatefmt.h:210
Plain, which means the absence of a qualifier.
Definition: reldatefmt.h:246
Formats simple relative dates.
Definition: reldatefmt.h:333
The number of styles.
Definition: reldatefmt.h:57
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
Use the shortest possible form.
Definition: reldatefmt.h:51
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
Count of items in this enum.
Definition: reldatefmt.h:252
UDateAbsoluteUnit
Represents an absolute unit.
Definition: reldatefmt.h:122
C++ API: Locale ID object.
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:245
Count of items in this enum.
Definition: reldatefmt.h:115
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UDateRelativeUnit
Represents the unit for formatting a relative date.
Definition: reldatefmt.h:67
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185