• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 #if U_SHOW_CPLUSPLUS_API
20 
21 #include "unicode/uobject.h"
22 #include "unicode/udisplaycontext.h"
23 #include "unicode/ureldatefmt.h"
24 #include "unicode/locid.h"
25 #include "unicode/formattedvalue.h"
26 
27 /**
28  * \file
29  * \brief C++ API: Formats relative dates such as "1 day ago" or "tomorrow"
30  */
31 
32 #if !UCONFIG_NO_FORMATTING
33 
34 /**
35  * Represents the unit for formatting a relative date. e.g "in 5 days"
36  * or "in 3 months"
37  * @stable ICU 53
38  */
39 typedef enum UDateRelativeUnit {
40 
41     /**
42      * Seconds
43      * @stable ICU 53
44      */
45     UDAT_RELATIVE_SECONDS,
46 
47     /**
48      * Minutes
49      * @stable ICU 53
50      */
51     UDAT_RELATIVE_MINUTES,
52 
53     /**
54      * Hours
55      * @stable ICU 53
56      */
57     UDAT_RELATIVE_HOURS,
58 
59     /**
60      * Days
61      * @stable ICU 53
62      */
63     UDAT_RELATIVE_DAYS,
64 
65     /**
66      * Weeks
67      * @stable ICU 53
68      */
69     UDAT_RELATIVE_WEEKS,
70 
71     /**
72      * Months
73      * @stable ICU 53
74      */
75     UDAT_RELATIVE_MONTHS,
76 
77     /**
78      * Years
79      * @stable ICU 53
80      */
81     UDAT_RELATIVE_YEARS,
82 
83 #ifndef U_HIDE_DEPRECATED_API
84     /**
85      * One more than the highest normal UDateRelativeUnit value.
86      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
87      */
88     UDAT_RELATIVE_UNIT_COUNT
89 #endif  // U_HIDE_DEPRECATED_API
90 } UDateRelativeUnit;
91 
92 /**
93  * Represents an absolute unit.
94  * @stable ICU 53
95  */
96 typedef enum UDateAbsoluteUnit {
97 
98     // Days of week have to remain together and in order from Sunday to
99     // Saturday.
100     /**
101      * Sunday
102      * @stable ICU 53
103      */
104     UDAT_ABSOLUTE_SUNDAY,
105 
106     /**
107      * Monday
108      * @stable ICU 53
109      */
110     UDAT_ABSOLUTE_MONDAY,
111 
112     /**
113      * Tuesday
114      * @stable ICU 53
115      */
116     UDAT_ABSOLUTE_TUESDAY,
117 
118     /**
119      * Wednesday
120      * @stable ICU 53
121      */
122     UDAT_ABSOLUTE_WEDNESDAY,
123 
124     /**
125      * Thursday
126      * @stable ICU 53
127      */
128     UDAT_ABSOLUTE_THURSDAY,
129 
130     /**
131      * Friday
132      * @stable ICU 53
133      */
134     UDAT_ABSOLUTE_FRIDAY,
135 
136     /**
137      * Saturday
138      * @stable ICU 53
139      */
140     UDAT_ABSOLUTE_SATURDAY,
141 
142     /**
143      * Day
144      * @stable ICU 53
145      */
146     UDAT_ABSOLUTE_DAY,
147 
148     /**
149      * Week
150      * @stable ICU 53
151      */
152     UDAT_ABSOLUTE_WEEK,
153 
154     /**
155      * Month
156      * @stable ICU 53
157      */
158     UDAT_ABSOLUTE_MONTH,
159 
160     /**
161      * Year
162      * @stable ICU 53
163      */
164     UDAT_ABSOLUTE_YEAR,
165 
166     /**
167      * Now
168      * @stable ICU 53
169      */
170     UDAT_ABSOLUTE_NOW,
171 
172     /**
173      * Quarter
174      * @stable ICU 63
175      */
176     UDAT_ABSOLUTE_QUARTER,
177 
178     /**
179      * Hour
180      * @stable ICU 65
181      */
182     UDAT_ABSOLUTE_HOUR,
183 
184     /**
185      * Minute
186      * @stable ICU 65
187      */
188     UDAT_ABSOLUTE_MINUTE,
189 
190 #ifndef U_HIDE_DEPRECATED_API
191     /**
192      * One more than the highest normal UDateAbsoluteUnit value.
193      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
194      */
195     UDAT_ABSOLUTE_UNIT_COUNT = UDAT_ABSOLUTE_NOW + 4
196 #endif  // U_HIDE_DEPRECATED_API
197 } UDateAbsoluteUnit;
198 
199 /**
200  * Represents a direction for an absolute unit e.g "Next Tuesday"
201  * or "Last Tuesday"
202  * @stable ICU 53
203  */
204 typedef enum UDateDirection {
205 
206     /**
207      * Two before. Not fully supported in every locale.
208      * @stable ICU 53
209      */
210     UDAT_DIRECTION_LAST_2,
211 
212     /**
213      * Last
214      * @stable ICU 53
215      */
216     UDAT_DIRECTION_LAST,
217 
218     /**
219      * This
220      * @stable ICU 53
221      */
222     UDAT_DIRECTION_THIS,
223 
224     /**
225      * Next
226      * @stable ICU 53
227      */
228     UDAT_DIRECTION_NEXT,
229 
230     /**
231      * Two after. Not fully supported in every locale.
232      * @stable ICU 53
233      */
234     UDAT_DIRECTION_NEXT_2,
235 
236     /**
237      * Plain, which means the absence of a qualifier.
238      * @stable ICU 53
239      */
240     UDAT_DIRECTION_PLAIN,
241 
242 #ifndef U_HIDE_DEPRECATED_API
243     /**
244      * One more than the highest normal UDateDirection value.
245      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
246      */
247     UDAT_DIRECTION_COUNT
248 #endif  // U_HIDE_DEPRECATED_API
249 } UDateDirection;
250 
251 U_NAMESPACE_BEGIN
252 
253 class BreakIterator;
254 class RelativeDateTimeCacheData;
255 class SharedNumberFormat;
256 class SharedPluralRules;
257 class SharedBreakIterator;
258 class NumberFormat;
259 class UnicodeString;
260 class FormattedRelativeDateTime;
261 class FormattedRelativeDateTimeData;
262 
263 /**
264  * An immutable class containing the result of a relative datetime formatting operation.
265  *
266  * Instances of this class are immutable and thread-safe.
267  *
268  * Not intended for public subclassing.
269  *
270  * @stable ICU 64
271  */
272 class U_I18N_API FormattedRelativeDateTime : public UMemory, public FormattedValue {
273   public:
274     /**
275      * Default constructor; makes an empty FormattedRelativeDateTime.
276      * @stable ICU 64
277      */
FormattedRelativeDateTime()278     FormattedRelativeDateTime() : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
279 
280     /**
281      * Move constructor: Leaves the source FormattedRelativeDateTime in an undefined state.
282      * @stable ICU 64
283      */
284     FormattedRelativeDateTime(FormattedRelativeDateTime&& src) noexcept;
285 
286     /**
287      * Destruct an instance of FormattedRelativeDateTime.
288      * @stable ICU 64
289      */
290     virtual ~FormattedRelativeDateTime() override;
291 
292     /** Copying not supported; use move constructor instead. */
293     FormattedRelativeDateTime(const FormattedRelativeDateTime&) = delete;
294 
295     /** Copying not supported; use move assignment instead. */
296     FormattedRelativeDateTime& operator=(const FormattedRelativeDateTime&) = delete;
297 
298     /**
299      * Move assignment: Leaves the source FormattedRelativeDateTime in an undefined state.
300      * @stable ICU 64
301      */
302     FormattedRelativeDateTime& operator=(FormattedRelativeDateTime&& src) noexcept;
303 
304     /** @copydoc FormattedValue::toString() */
305     UnicodeString toString(UErrorCode& status) const override;
306 
307     /** @copydoc FormattedValue::toTempString() */
308     UnicodeString toTempString(UErrorCode& status) const override;
309 
310     /** @copydoc FormattedValue::appendTo() */
311     Appendable &appendTo(Appendable& appendable, UErrorCode& status) const override;
312 
313     /** @copydoc FormattedValue::nextPosition() */
314     UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const override;
315 
316   private:
317     FormattedRelativeDateTimeData *fData;
318     UErrorCode fErrorCode;
FormattedRelativeDateTime(FormattedRelativeDateTimeData * results)319     explicit FormattedRelativeDateTime(FormattedRelativeDateTimeData *results)
320         : fData(results), fErrorCode(U_ZERO_ERROR) {}
FormattedRelativeDateTime(UErrorCode errorCode)321     explicit FormattedRelativeDateTime(UErrorCode errorCode)
322         : fData(nullptr), fErrorCode(errorCode) {}
323     friend class RelativeDateTimeFormatter;
324 };
325 
326 /**
327  * Formats simple relative dates. There are two types of relative dates that
328  * it handles:
329  * <ul>
330  *   <li>relative dates with a quantity e.g "in 5 days"</li>
331  *   <li>relative dates without a quantity e.g "next Tuesday"</li>
332  * </ul>
333  * <p>
334  * This API is very basic and is intended to be a building block for more
335  * fancy APIs. The caller tells it exactly what to display in a locale
336  * independent way. While this class automatically provides the correct plural
337  * forms, the grammatical form is otherwise as neutral as possible. It is the
338  * caller's responsibility to handle cut-off logic such as deciding between
339  * displaying "in 7 days" or "in 1 week." This API supports relative dates
340  * involving one single unit. This API does not support relative dates
341  * involving compound units,
342  * e.g "in 5 days and 4 hours" nor does it support parsing.
343  * <p>
344  * This class is mostly thread safe and immutable with the following caveats:
345  * 1. The assignment operator violates Immutability. It must not be used
346  *    concurrently with other operations.
347  * 2. Caller must not hold onto adopted pointers.
348  * <p>
349  * This class is not intended for public subclassing.
350  * <p>
351  * Here are some examples of use:
352  * <blockquote>
353  * <pre>
354  * UErrorCode status = U_ZERO_ERROR;
355  * UnicodeString appendTo;
356  * RelativeDateTimeFormatter fmt(status);
357  * // Appends "in 1 day"
358  * fmt.format(
359  *     1, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, appendTo, status);
360  * // Appends "in 3 days"
361  * fmt.format(
362  *     3, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, appendTo, status);
363  * // Appends "3.2 years ago"
364  * fmt.format(
365  *     3.2, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, appendTo, status);
366  * // Appends "last Sunday"
367  * fmt.format(UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, appendTo, status);
368  * // Appends "this Sunday"
369  * fmt.format(UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, appendTo, status);
370  * // Appends "next Sunday"
371  * fmt.format(UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, appendTo, status);
372  * // Appends "Sunday"
373  * fmt.format(UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, appendTo, status);
374  *
375  * // Appends "yesterday"
376  * fmt.format(UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, appendTo, status);
377  * // Appends "today"
378  * fmt.format(UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, appendTo, status);
379  * // Appends "tomorrow"
380  * fmt.format(UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, appendTo, status);
381  * // Appends "now"
382  * fmt.format(UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, appendTo, status);
383  *
384  * </pre>
385  * </blockquote>
386  * <p>
387  * In the future, we may add more forms, such as abbreviated/short forms
388  * (3 secs ago), and relative day periods ("yesterday afternoon"), etc.
389  *
390  * The RelativeDateTimeFormatter class is not intended for public subclassing.
391  *
392  * @stable ICU 53
393  */
394 class U_I18N_API RelativeDateTimeFormatter : public UObject {
395 public:
396 
397     /**
398      * Create RelativeDateTimeFormatter with default locale.
399      * @stable ICU 53
400      */
401     RelativeDateTimeFormatter(UErrorCode& status);
402 
403     /**
404      * Create RelativeDateTimeFormatter with given locale.
405      * @stable ICU 53
406      */
407     RelativeDateTimeFormatter(const Locale& locale, UErrorCode& status);
408 
409     /**
410      * Create RelativeDateTimeFormatter with given locale and NumberFormat.
411      *
412      * @param locale the locale
413      * @param nfToAdopt Constructed object takes ownership of this pointer.
414      *   It is an error for caller to delete this pointer or change its
415      *   contents after calling this constructor.
416      * @param status Any error is returned here.
417      * @stable ICU 53
418      */
419     RelativeDateTimeFormatter(
420         const Locale& locale, NumberFormat *nfToAdopt, UErrorCode& status);
421 
422     /**
423      * Create RelativeDateTimeFormatter with given locale, NumberFormat,
424      * and capitalization context.
425      *
426      * @param locale the locale
427      * @param nfToAdopt Constructed object takes ownership of this pointer.
428      *   It is an error for caller to delete this pointer or change its
429      *   contents after calling this constructor. Caller may pass nullptr for
430      *   this argument if they want default number format behavior.
431      * @param style the format style. The UDAT_RELATIVE bit field has no effect.
432      * @param capitalizationContext A value from UDisplayContext that pertains to
433      * capitalization.
434      * @param status Any error is returned here.
435      * @stable ICU 54
436      */
437     RelativeDateTimeFormatter(
438             const Locale& locale,
439             NumberFormat *nfToAdopt,
440             UDateRelativeDateTimeFormatterStyle style,
441             UDisplayContext capitalizationContext,
442             UErrorCode& status);
443 
444     /**
445      * Copy constructor.
446      * @stable ICU 53
447      */
448     RelativeDateTimeFormatter(const RelativeDateTimeFormatter& other);
449 
450     /**
451      * Assignment operator.
452      * @stable ICU 53
453      */
454     RelativeDateTimeFormatter& operator=(
455             const RelativeDateTimeFormatter& other);
456 
457     /**
458      * Destructor.
459      * @stable ICU 53
460      */
461     virtual ~RelativeDateTimeFormatter();
462 
463     /**
464      * Formats a relative date with a quantity such as "in 5 days" or
465      * "3 months ago"
466      *
467      * This method returns a String. To get more information about the
468      * formatting result, use formatToValue().
469      *
470      * @param quantity The numerical amount e.g 5. This value is formatted
471      * according to this object's NumberFormat object.
472      * @param direction NEXT means a future relative date; LAST means a past
473      * relative date. If direction is anything else, this method sets
474      * status to U_ILLEGAL_ARGUMENT_ERROR.
475      * @param unit the unit e.g day? month? year?
476      * @param appendTo The string to which the formatted result will be
477      *  appended
478      * @param status ICU error code returned here.
479      * @return appendTo
480      * @stable ICU 53
481      */
482     UnicodeString& format(
483             double quantity,
484             UDateDirection direction,
485             UDateRelativeUnit unit,
486             UnicodeString& appendTo,
487             UErrorCode& status) const;
488 
489     /**
490      * Formats a relative date with a quantity such as "in 5 days" or
491      * "3 months ago"
492      *
493      * This method returns a FormattedRelativeDateTime, which exposes more
494      * information than the String returned by format().
495      *
496      * @param quantity The numerical amount e.g 5. This value is formatted
497      * according to this object's NumberFormat object.
498      * @param direction NEXT means a future relative date; LAST means a past
499      * relative date. If direction is anything else, this method sets
500      * status to U_ILLEGAL_ARGUMENT_ERROR.
501      * @param unit the unit e.g day? month? year?
502      * @param status ICU error code returned here.
503      * @return The formatted relative datetime
504      * @stable ICU 64
505      */
506     FormattedRelativeDateTime formatToValue(
507             double quantity,
508             UDateDirection direction,
509             UDateRelativeUnit unit,
510             UErrorCode& status) const;
511 
512     /**
513      * Formats a relative date without a quantity.
514      *
515      * This method returns a String. To get more information about the
516      * formatting result, use formatToValue().
517      *
518      * @param direction NEXT, LAST, THIS, etc.
519      * @param unit e.g SATURDAY, DAY, MONTH
520      * @param appendTo The string to which the formatted result will be
521      *  appended. If the value of direction is documented as not being fully
522      *  supported in all locales then this method leaves appendTo unchanged if
523      *  no format string is available.
524      * @param status ICU error code returned here.
525      * @return appendTo
526      * @stable ICU 53
527      */
528     UnicodeString& format(
529             UDateDirection direction,
530             UDateAbsoluteUnit unit,
531             UnicodeString& appendTo,
532             UErrorCode& status) const;
533 
534     /**
535      * Formats a relative date without a quantity.
536      *
537      * This method returns a FormattedRelativeDateTime, which exposes more
538      * information than the String returned by format().
539      *
540      * If the string is not available in the requested locale, the return
541      * value will be empty (calling toString will give an empty string).
542      *
543      * @param direction NEXT, LAST, THIS, etc.
544      * @param unit e.g SATURDAY, DAY, MONTH
545      * @param status ICU error code returned here.
546      * @return The formatted relative datetime
547      * @stable ICU 64
548      */
549     FormattedRelativeDateTime formatToValue(
550             UDateDirection direction,
551             UDateAbsoluteUnit unit,
552             UErrorCode& status) const;
553 
554     /**
555      * Format a combination of URelativeDateTimeUnit and numeric offset
556      * using a numeric style, e.g. "1 week ago", "in 1 week",
557      * "5 weeks ago", "in 5 weeks".
558      *
559      * This method returns a String. To get more information about the
560      * formatting result, use formatNumericToValue().
561      *
562      * @param offset    The signed offset for the specified unit. This
563      *                  will be formatted according to this object's
564      *                  NumberFormat object.
565      * @param unit      The unit to use when formatting the relative
566      *                  date, e.g. UDAT_REL_UNIT_WEEK,
567      *                  UDAT_REL_UNIT_FRIDAY.
568      * @param appendTo  The string to which the formatted result will be
569      *                  appended.
570      * @param status    ICU error code returned here.
571      * @return          appendTo
572      * @stable ICU 57
573      */
574     UnicodeString& formatNumeric(
575             double offset,
576             URelativeDateTimeUnit unit,
577             UnicodeString& appendTo,
578             UErrorCode& status) const;
579 
580     /**
581      * Format a combination of URelativeDateTimeUnit and numeric offset
582      * using a numeric style, e.g. "1 week ago", "in 1 week",
583      * "5 weeks ago", "in 5 weeks".
584      *
585      * This method returns a FormattedRelativeDateTime, which exposes more
586      * information than the String returned by formatNumeric().
587      *
588      * @param offset    The signed offset for the specified unit. This
589      *                  will be formatted according to this object's
590      *                  NumberFormat object.
591      * @param unit      The unit to use when formatting the relative
592      *                  date, e.g. UDAT_REL_UNIT_WEEK,
593      *                  UDAT_REL_UNIT_FRIDAY.
594      * @param status    ICU error code returned here.
595      * @return          The formatted relative datetime
596      * @stable ICU 64
597      */
598     FormattedRelativeDateTime formatNumericToValue(
599             double offset,
600             URelativeDateTimeUnit unit,
601             UErrorCode& status) const;
602 
603     /**
604      * Format a combination of URelativeDateTimeUnit and numeric offset
605      * using a text style if possible, e.g. "last week", "this week",
606      * "next week", "yesterday", "tomorrow". Falls back to numeric
607      * style if no appropriate text term is available for the specified
608      * offset in the object's locale.
609      *
610      * This method returns a String. To get more information about the
611      * formatting result, use formatToValue().
612      *
613      * @param offset    The signed offset for the specified unit.
614      * @param unit      The unit to use when formatting the relative
615      *                  date, e.g. UDAT_REL_UNIT_WEEK,
616      *                  UDAT_REL_UNIT_FRIDAY.
617      * @param appendTo  The string to which the formatted result will be
618      *                  appended.
619      * @param status    ICU error code returned here.
620      * @return          appendTo
621      * @stable ICU 57
622      */
623     UnicodeString& format(
624             double offset,
625             URelativeDateTimeUnit unit,
626             UnicodeString& appendTo,
627             UErrorCode& status) const;
628 
629     /**
630      * Format a combination of URelativeDateTimeUnit and numeric offset
631      * using a text style if possible, e.g. "last week", "this week",
632      * "next week", "yesterday", "tomorrow". Falls back to numeric
633      * style if no appropriate text term is available for the specified
634      * offset in the object's locale.
635      *
636      * This method returns a FormattedRelativeDateTime, which exposes more
637      * information than the String returned by format().
638      *
639      * @param offset    The signed offset for the specified unit.
640      * @param unit      The unit to use when formatting the relative
641      *                  date, e.g. UDAT_REL_UNIT_WEEK,
642      *                  UDAT_REL_UNIT_FRIDAY.
643      * @param status    ICU error code returned here.
644      * @return          The formatted relative datetime
645      * @stable ICU 64
646      */
647     FormattedRelativeDateTime formatToValue(
648             double offset,
649             URelativeDateTimeUnit unit,
650             UErrorCode& status) const;
651 
652     /**
653      * Combines a relative date string and a time string in this object's
654      * locale. This is done with the same date-time separator used for the
655      * default calendar in this locale.
656      *
657      * @param relativeDateString the relative date, e.g 'yesterday'
658      * @param timeString the time e.g '3:45'
659      * @param appendTo concatenated date and time appended here
660      * @param status ICU error code returned here.
661      * @return appendTo
662      * @stable ICU 53
663      */
664     UnicodeString& combineDateAndTime(
665             const UnicodeString& relativeDateString,
666             const UnicodeString& timeString,
667             UnicodeString& appendTo,
668             UErrorCode& status) const;
669 
670     /**
671      * Returns the NumberFormat this object is using.
672      *
673      * @stable ICU 53
674      */
675     const NumberFormat& getNumberFormat() const;
676 
677     /**
678      * Returns the capitalization context.
679      *
680      * @stable ICU 54
681      */
682     UDisplayContext getCapitalizationContext() const;
683 
684     /**
685      * Returns the format style.
686      *
687      * @stable ICU 54
688      */
689     UDateRelativeDateTimeFormatterStyle getFormatStyle() const;
690 
691 private:
692     const RelativeDateTimeCacheData* fCache;
693     const SharedNumberFormat *fNumberFormat;
694     const SharedPluralRules *fPluralRules;
695     UDateRelativeDateTimeFormatterStyle fStyle;
696     UDisplayContext fContext;
697 #if !UCONFIG_NO_BREAK_ITERATION
698     const SharedBreakIterator *fOptBreakIterator;
699 #else
700     std::nullptr_t fOptBreakIterator = nullptr;
701 #endif // !UCONFIG_NO_BREAK_ITERATION
702     Locale fLocale;
703     void init(
704             NumberFormat *nfToAdopt,
705 #if !UCONFIG_NO_BREAK_ITERATION
706             BreakIterator *brkIter,
707 #else
708             std::nullptr_t,
709 #endif // !UCONFIG_NO_BREAK_ITERATION
710             UErrorCode &status);
711     UnicodeString& adjustForContext(UnicodeString &) const;
712     UBool checkNoAdjustForContext(UErrorCode& status) const;
713 
714     template<typename F, typename... Args>
715     UnicodeString& doFormat(
716             F callback,
717             UnicodeString& appendTo,
718             UErrorCode& status,
719             Args... args) const;
720 
721     template<typename F, typename... Args>
722     FormattedRelativeDateTime doFormatToValue(
723             F callback,
724             UErrorCode& status,
725             Args... args) const;
726 
727     void formatImpl(
728             double quantity,
729             UDateDirection direction,
730             UDateRelativeUnit unit,
731             FormattedRelativeDateTimeData& output,
732             UErrorCode& status) const;
733     void formatAbsoluteImpl(
734             UDateDirection direction,
735             UDateAbsoluteUnit unit,
736             FormattedRelativeDateTimeData& output,
737             UErrorCode& status) const;
738     void formatNumericImpl(
739             double offset,
740             URelativeDateTimeUnit unit,
741             FormattedRelativeDateTimeData& output,
742             UErrorCode& status) const;
743     void formatRelativeImpl(
744             double offset,
745             URelativeDateTimeUnit unit,
746             FormattedRelativeDateTimeData& output,
747             UErrorCode& status) const;
748 };
749 
750 U_NAMESPACE_END
751 
752 #endif /* !UCONFIG_NO_FORMATTING */
753 
754 #endif /* U_SHOW_CPLUSPLUS_API */
755 
756 #endif /* __RELDATEFMT_H */
757