OLD | NEW |
1 /* | 1 /* |
2 *******************************************************************************
* | 2 *******************************************************************************
* |
3 * Copyright (C) 1997-2013, International Business Machines | 3 * Copyright (C) 1997-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 *******************************************************************************
* | 5 *******************************************************************************
* |
6 * | 6 * |
7 * File DATEFMT.H | 7 * File DATEFMT.H |
8 * | 8 * |
9 * Modification History: | 9 * Modification History: |
10 * | 10 * |
11 * Date Name Description | 11 * Date Name Description |
12 * 02/19/97 aliu Converted from java. | 12 * 02/19/97 aliu Converted from java. |
13 * 04/01/97 aliu Added support for centuries. | 13 * 04/01/97 aliu Added support for centuries. |
14 * 07/23/98 stephen JDK 1.2 sync | 14 * 07/23/98 stephen JDK 1.2 sync |
15 * 11/15/99 weiv Added support for week of year/day of week formatti
ng | 15 * 11/15/99 weiv Added support for week of year/day of week formatti
ng |
16 *******************************************************************************
* | 16 *******************************************************************************
* |
17 */ | 17 */ |
18 | 18 |
19 #ifndef DATEFMT_H | 19 #ifndef DATEFMT_H |
20 #define DATEFMT_H | 20 #define DATEFMT_H |
21 | 21 |
22 #include "unicode/utypes.h" | 22 #include "unicode/utypes.h" |
23 | 23 |
24 #if !UCONFIG_NO_FORMATTING | 24 #if !UCONFIG_NO_FORMATTING |
25 | 25 |
26 #include "unicode/udat.h" | 26 #include "unicode/udat.h" |
27 #include "unicode/calendar.h" | 27 #include "unicode/calendar.h" |
28 #include "unicode/numfmt.h" | 28 #include "unicode/numfmt.h" |
29 #include "unicode/format.h" | 29 #include "unicode/format.h" |
30 #include "unicode/locid.h" | 30 #include "unicode/locid.h" |
31 #include "unicode/enumset.h" | 31 #include "unicode/enumset.h" |
| 32 #include "unicode/udisplaycontext.h" |
32 | 33 |
33 /** | 34 /** |
34 * \file | 35 * \file |
35 * \brief C++ API: Abstract class for converting dates. | 36 * \brief C++ API: Abstract class for converting dates. |
36 */ | 37 */ |
37 | 38 |
38 U_NAMESPACE_BEGIN | 39 U_NAMESPACE_BEGIN |
39 | 40 |
40 class TimeZone; | 41 class TimeZone; |
41 class DateTimePatternGenerator; | 42 class DateTimePatternGenerator; |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 /** | 574 /** |
574 * Gets the set of locales for which DateFormats are installed. | 575 * Gets the set of locales for which DateFormats are installed. |
575 * @param count Filled in with the number of locales in the list that is ret
urned. | 576 * @param count Filled in with the number of locales in the list that is ret
urned. |
576 * @return the set of locales for which DateFormats are installed. The call
er | 577 * @return the set of locales for which DateFormats are installed. The call
er |
577 * does NOT own this list and must not delete it. | 578 * does NOT own this list and must not delete it. |
578 * @stable ICU 2.0 | 579 * @stable ICU 2.0 |
579 */ | 580 */ |
580 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); | 581 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count); |
581 | 582 |
582 /** | 583 /** |
583 * Returns true if the encapsulated Calendar object is set for lenient parsi
ng. | 584 * Returns whether both date/time parsing in the encapsulated Calendar objec
t and DateFormat whitespace & |
| 585 * numeric processing is lenient. |
584 * @stable ICU 2.0 | 586 * @stable ICU 2.0 |
585 */ | 587 */ |
586 virtual UBool isLenient(void) const; | 588 virtual UBool isLenient(void) const; |
587 | 589 |
588 /** | 590 /** |
589 * Specify whether or not date/time parsing is to be lenient. With lenient | 591 * Specifies whether date/time parsing is to be lenient. With |
590 * parsing, the parser may use heuristics to interpret inputs that do not | 592 * lenient parsing, the parser may use heuristics to interpret inputs that |
591 * precisely match this object's format. With strict parsing, inputs must | 593 * do not precisely match this object's format. Without lenient parsing, |
592 * match this object's format. | 594 * inputs must match this object's format more closely. |
593 * | 595 * |
594 * Note: This method is specific to the encapsulated Calendar object. DateF
ormat | 596 * Note: ICU 53 introduced finer grained control of leniency (and added |
595 * leniency aspects are controlled by setBooleanAttribute. | 597 * new control points) making the preferred method a combination of |
| 598 * setCalendarLenient() & setBooleanAttribute() calls. |
| 599 * This method supports prior functionality but may not support all |
| 600 * future leniency control & behavior of DateFormat. For control of pre 53 l
eniency, |
| 601 * Calendar and DateFormat whitespace & numeric tolerance, this method is sa
fe to |
| 602 * use. However, mixing leniency control via this method and modification of
the |
| 603 * newer attributes via setBooleanAttribute() may produce undesirable |
| 604 * results. |
596 * | 605 * |
597 * @param lenient True specifies date/time interpretation to be lenient. | 606 * @param lenient True specifies date/time interpretation to be lenient. |
598 * @see Calendar::setLenient | 607 * @see Calendar::setLenient |
599 * @stable ICU 2.0 | 608 * @stable ICU 2.0 |
600 */ | 609 */ |
601 virtual void setLenient(UBool lenient); | 610 virtual void setLenient(UBool lenient); |
602 | 611 |
| 612 |
| 613 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ |
| 614 /** |
| 615 * Returns whether date/time parsing in the encapsulated Calendar object pro
cessing is lenient. |
| 616 * @draft ICU 53 |
| 617 */ |
| 618 virtual UBool isCalendarLenient(void) const; |
| 619 |
| 620 |
| 621 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ |
| 622 /** |
| 623 * Specifies whether encapsulated Calendar date/time parsing is to be lenien
t. With |
| 624 * lenient parsing, the parser may use heuristics to interpret inputs that |
| 625 * do not precisely match this object's format. Without lenient parsing, |
| 626 * inputs must match this object's format more closely. |
| 627 * @param lenient when true, parsing is lenient |
| 628 * @see com.ibm.icu.util.Calendar#setLenient |
| 629 * @draft ICU 53 |
| 630 */ |
| 631 virtual void setCalendarLenient(UBool lenient); |
| 632 |
| 633 |
603 /** | 634 /** |
604 * Gets the calendar associated with this date/time formatter. | 635 * Gets the calendar associated with this date/time formatter. |
| 636 * The calendar is owned by the formatter and must not be modified. |
| 637 * Also, the calendar does not reflect the results of a parse operation. |
| 638 * To parse to a calendar, use {@link #parse(const UnicodeString&, Calendar&
cal, ParsePosition&) const parse(const UnicodeString&, Calendar& cal, ParsePosi
tion&)} |
605 * @return the calendar associated with this date/time formatter. | 639 * @return the calendar associated with this date/time formatter. |
606 * @stable ICU 2.0 | 640 * @stable ICU 2.0 |
607 */ | 641 */ |
608 virtual const Calendar* getCalendar(void) const; | 642 virtual const Calendar* getCalendar(void) const; |
609 | 643 |
610 /** | 644 /** |
611 * Set the calendar to be used by this date format. Initially, the default | 645 * Set the calendar to be used by this date format. Initially, the default |
612 * calendar for the specified or default locale is used. The caller should | 646 * calendar for the specified or default locale is used. The caller should |
613 * not delete the Calendar object after it is adopted by this call. | 647 * not delete the Calendar object after it is adopted by this call. |
614 * Adopting a new calendar will change to the default symbols. | 648 * Adopting a new calendar will change to the default symbols. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 */ | 700 */ |
667 virtual void adoptTimeZone(TimeZone* zoneToAdopt); | 701 virtual void adoptTimeZone(TimeZone* zoneToAdopt); |
668 | 702 |
669 /** | 703 /** |
670 * Sets the time zone for the calendar of this DateFormat object. | 704 * Sets the time zone for the calendar of this DateFormat object. |
671 * @param zone the new time zone. | 705 * @param zone the new time zone. |
672 * @stable ICU 2.0 | 706 * @stable ICU 2.0 |
673 */ | 707 */ |
674 virtual void setTimeZone(const TimeZone& zone); | 708 virtual void setTimeZone(const TimeZone& zone); |
675 | 709 |
| 710 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ |
| 711 /** |
| 712 * Set a particular UDisplayContext value in the formatter, such as |
| 713 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. |
| 714 * @param value The UDisplayContext value to set. |
| 715 * @param status Input/output status. If at entry this indicates a failure |
| 716 * status, the function will do nothing; otherwise this will b
e |
| 717 * updated with any new status from the function. |
| 718 * @draft ICU 53 |
| 719 */ |
| 720 virtual void setContext(UDisplayContext value, UErrorCode& status); |
| 721 |
| 722 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ |
| 723 /** |
| 724 * Get the formatter's UDisplayContext value for the specified UDisplayConte
xtType, |
| 725 * such as UDISPCTX_TYPE_CAPITALIZATION. |
| 726 * @param type The UDisplayContextType whose value to return |
| 727 * @param status Input/output status. If at entry this indicates a failure |
| 728 * status, the function will do nothing; otherwise this will b
e |
| 729 * updated with any new status from the function. |
| 730 * @return The UDisplayContextValue for the specified type. |
| 731 * @draft ICU 53 |
| 732 */ |
| 733 virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& sta
tus) const; |
| 734 |
| 735 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since i
t is virtual */ |
676 /** | 736 /** |
677 * Set an boolean attribute on this DateFormat. | 737 * Sets an boolean attribute on this DateFormat. |
678 * May return U_UNSUPPORTED_ERROR if this instance does not support | 738 * May return U_UNSUPPORTED_ERROR if this instance does not support |
679 * the specified attribute. | 739 * the specified attribute. |
680 * @param attr the attribute to set | 740 * @param attr the attribute to set |
681 * @param newvalue new value | 741 * @param newvalue new value |
682 * @param status the error type | 742 * @param status the error type |
683 * @return *this - for chaining (example: format.setAttribute(...).setAttrib
ute(...) ) | 743 * @return *this - for chaining (example: format.setAttribute(...).setAttrib
ute(...) ) |
684 * @internal ICU technology preview | 744 * @draft ICU 53 |
685 */ | 745 */ |
686 | 746 |
687 virtual DateFormat& U_EXPORT2 setBooleanAttribute(UDateFormatBooleanAttribu
te attr, | 747 virtual DateFormat& U_EXPORT2 setBooleanAttribute(UDateFormatBooleanAttribu
te attr, |
688 UBool ne
wvalue, | 748 UBool ne
wvalue, |
689 UErrorCo
de &status); | 749 UErrorCo
de &status); |
690 | 750 |
| 751 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ |
691 /** | 752 /** |
692 * Get an boolean from this DateFormat | 753 * Returns a boolean from this DateFormat |
693 * May return U_UNSUPPORTED_ERROR if this instance does not support | 754 * May return U_UNSUPPORTED_ERROR if this instance does not support |
694 * the specified attribute. | 755 * the specified attribute. |
695 * @param attr the attribute to set | 756 * @param attr the attribute to set |
696 * @param status the error type | 757 * @param status the error type |
697 * @return the attribute value. Undefined if there is an error. | 758 * @return the attribute value. Undefined if there is an error. |
698 * @internal ICU technology preview | 759 * @draft ICU 53 |
699 */ | 760 */ |
700 virtual UBool U_EXPORT2 getBooleanAttribute(UDateFormatBooleanAttribute attr
, UErrorCode &status) const; | 761 virtual UBool U_EXPORT2 getBooleanAttribute(UDateFormatBooleanAttribute attr
, UErrorCode &status) const; |
701 | 762 |
702 protected: | 763 protected: |
703 /** | 764 /** |
704 * Default constructor. Creates a DateFormat with no Calendar or NumberForm
at | 765 * Default constructor. Creates a DateFormat with no Calendar or NumberForm
at |
705 * associated with it. This constructor depends on the subclasses to fill i
n | 766 * associated with it. This constructor depends on the subclasses to fill i
n |
706 * the calendar and numberFormat fields. | 767 * the calendar and numberFormat fields. |
707 * @stable ICU 2.0 | 768 * @stable ICU 2.0 |
708 */ | 769 */ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 */ | 809 */ |
749 static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, cons
t Locale& inLocale); | 810 static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, cons
t Locale& inLocale); |
750 | 811 |
751 | 812 |
752 /** | 813 /** |
753 * enum set of active boolean attributes for this instance | 814 * enum set of active boolean attributes for this instance |
754 */ | 815 */ |
755 EnumSet<UDateFormatBooleanAttribute, 0, UDAT_BOOLEAN_ATTRIBUTE_COUNT> fBoolF
lags; | 816 EnumSet<UDateFormatBooleanAttribute, 0, UDAT_BOOLEAN_ATTRIBUTE_COUNT> fBoolF
lags; |
756 | 817 |
757 | 818 |
| 819 UDisplayContext fCapitalizationContext; |
| 820 |
758 public: | 821 public: |
759 #ifndef U_HIDE_OBSOLETE_API | 822 #ifndef U_HIDE_OBSOLETE_API |
760 /** | 823 /** |
761 * Field selector for FieldPosition for DateFormat fields. | 824 * Field selector for FieldPosition for DateFormat fields. |
762 * @obsolete ICU 3.4 use UDateFormatField instead, since this API will be | 825 * @obsolete ICU 3.4 use UDateFormatField instead, since this API will be |
763 * removed in that release | 826 * removed in that release |
764 */ | 827 */ |
765 enum EField | 828 enum EField |
766 { | 829 { |
767 // Obsolete; use UDateFormatField instead | 830 // Obsolete; use UDateFormatField instead |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 }; | 874 }; |
812 #endif /* U_HIDE_OBSOLETE_API */ | 875 #endif /* U_HIDE_OBSOLETE_API */ |
813 }; | 876 }; |
814 | 877 |
815 U_NAMESPACE_END | 878 U_NAMESPACE_END |
816 | 879 |
817 #endif /* #if !UCONFIG_NO_FORMATTING */ | 880 #endif /* #if !UCONFIG_NO_FORMATTING */ |
818 | 881 |
819 #endif // _DATEFMT | 882 #endif // _DATEFMT |
820 //eof | 883 //eof |
OLD | NEW |