ICU 60.2  60.2
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_DEPRECATED_API
169 
174 #endif // U_HIDE_DEPRECATED_API
176 
182 typedef enum UDateDirection {
183 
189 
195 
201 
207 
213 
219 
220 #ifndef U_HIDE_DEPRECATED_API
221 
226 #endif // U_HIDE_DEPRECATED_API
228 
229 #if !UCONFIG_NO_BREAK_ITERATION
230 
232 
233 class BreakIterator;
234 class RelativeDateTimeCacheData;
235 class SharedNumberFormat;
236 class SharedPluralRules;
237 class SharedBreakIterator;
238 class NumberFormat;
239 class UnicodeString;
240 
310 public:
311 
317 
322  RelativeDateTimeFormatter(const Locale& locale, UErrorCode& status);
323 
335  const Locale& locale, NumberFormat *nfToAdopt, UErrorCode& status);
336 
353  const Locale& locale,
354  NumberFormat *nfToAdopt,
356  UDisplayContext capitalizationContext,
357  UErrorCode& status);
358 
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,
438  UnicodeString& appendTo,
439  UErrorCode& status) const;
440 
458  UnicodeString& format(
459  double offset,
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;
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 
519 
520 #endif /* !UCONFIG_NO_BREAK_ITERATION */
521 #endif /* !UCONFIG_NO_FORMATTING */
522 #endif /* __RELDATEFMT_H */
One more than the highest normal UDateAbsoluteUnit value.
Definition: reldatefmt.h:173
URelativeDateTimeUnit
Represents the unit for formatting a relative date.
Definition: ureldatefmt.h:77
Abstract base class for all number formats.
Definition: numfmt.h:174
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:360
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
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:182
Plain, which means the absence of a qualifier.
Definition: reldatefmt.h:218
Formats simple relative dates.
Definition: reldatefmt.h:309
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:132
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
One more than the highest normal UDateDirection value.
Definition: reldatefmt.h:225
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:286
One more than the highest normal UDateRelativeUnit value.
Definition: reldatefmt.h:84
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
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:188