ICU 63.1  63.1
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"
20 #include "unicode/ureldatefmt.h"
21 #include "unicode/locid.h"
22 
28 #if !UCONFIG_NO_FORMATTING
29 
35 typedef enum UDateRelativeUnit {
36 
42 
48 
54 
60 
66 
72 
78 
79 #ifndef U_HIDE_DEPRECATED_API
80 
85 #endif // U_HIDE_DEPRECATED_API
87 
92 typedef enum UDateAbsoluteUnit {
93 
94  // Days of week have to remain together and in order from Sunday to
95  // Saturday.
101 
107 
113 
119 
125 
131 
137 
143 
149 
155 
161 
167 
168 #ifndef U_HIDE_DRAFT_API
169 
174 #endif // U_HIDE_DRAFT_API
175 
176 #ifndef U_HIDE_DEPRECATED_API
177 
182 #endif // U_HIDE_DEPRECATED_API
184 
190 typedef enum UDateDirection {
191 
197 
203 
209 
215 
221 
227 
228 #ifndef U_HIDE_DEPRECATED_API
229 
234 #endif // U_HIDE_DEPRECATED_API
236 
237 #if !UCONFIG_NO_BREAK_ITERATION
238 
240 
241 class BreakIterator;
242 class RelativeDateTimeCacheData;
243 class SharedNumberFormat;
244 class SharedPluralRules;
245 class SharedBreakIterator;
246 class NumberFormat;
247 class UnicodeString;
248 
318 public:
319 
325 
330  RelativeDateTimeFormatter(const Locale& locale, UErrorCode& status);
331 
343  const Locale& locale, NumberFormat *nfToAdopt, UErrorCode& status);
344 
361  const Locale& locale,
362  NumberFormat *nfToAdopt,
364  UDisplayContext capitalizationContext,
365  UErrorCode& status);
366 
372 
377  RelativeDateTimeFormatter& operator=(
378  const RelativeDateTimeFormatter& other);
379 
384  virtual ~RelativeDateTimeFormatter();
385 
401  UnicodeString& format(
402  double quantity,
403  UDateDirection direction,
404  UDateRelativeUnit unit,
405  UnicodeString& appendTo,
406  UErrorCode& status) const;
407 
420  UnicodeString& format(
421  UDateDirection direction,
422  UDateAbsoluteUnit unit,
423  UnicodeString& appendTo,
424  UErrorCode& status) const;
425 
443  UnicodeString& formatNumeric(
444  double offset,
446  UnicodeString& appendTo,
447  UErrorCode& status) const;
448 
466  UnicodeString& format(
467  double offset,
469  UnicodeString& appendTo,
470  UErrorCode& status) const;
471 
484  UnicodeString& combineDateAndTime(
485  const UnicodeString& relativeDateString,
486  const UnicodeString& timeString,
487  UnicodeString& appendTo,
488  UErrorCode& status) const;
489 
495  const NumberFormat& getNumberFormat() const;
496 
502  UDisplayContext getCapitalizationContext() const;
503 
509  UDateRelativeDateTimeFormatterStyle getFormatStyle() const;
510 
511 private:
512  const RelativeDateTimeCacheData* fCache;
513  const SharedNumberFormat *fNumberFormat;
514  const SharedPluralRules *fPluralRules;
516  UDisplayContext fContext;
517  const SharedBreakIterator *fOptBreakIterator;
518  Locale fLocale;
519  void init(
520  NumberFormat *nfToAdopt,
521  BreakIterator *brkIter,
522  UErrorCode &status);
523  void adjustForContext(UnicodeString &) const;
524 };
525 
527 
528 #endif /* !UCONFIG_NO_BREAK_ITERATION */
529 #endif /* !UCONFIG_NO_FORMATTING */
530 #endif /* __RELDATEFMT_H */
One more than the highest normal UDateAbsoluteUnit value.
Definition: reldatefmt.h:181
URelativeDateTimeUnit
Represents the unit for formatting a relative date.
Definition: ureldatefmt.h:77
UDisplayContext
Display context settings.
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:301
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
C API: URelativeDateTimeFormatter, relative date formatting of unit + numeric offset.
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:102
UDateRelativeDateTimeFormatterStyle
The formatting style.
Definition: ureldatefmt.h:44
UDateDirection
Represents a direction for an absolute unit e.g "Next Tuesday" or "Last Tuesday". ...
Definition: reldatefmt.h:190
Plain, which means the absence of a qualifier.
Definition: reldatefmt.h:226
Formats simple relative dates.
Definition: reldatefmt.h:317
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:138
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
One more than the highest normal UDateDirection value.
Definition: reldatefmt.h:233
UDateAbsoluteUnit
Represents an absolute unit.
Definition: reldatefmt.h:92
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:289
One more than the highest normal UDateRelativeUnit value.
Definition: reldatefmt.h:84
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:220
UDateRelativeUnit
Represents the unit for formatting a relative date.
Definition: reldatefmt.h:35
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:192