1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2008-2009, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
11 *******************************************************************************
17 #include "unicode/utypes.h"
19 #if U_SHOW_CPLUSPLUS_API
21 #include "unicode/uobject.h"
25 * \brief C++ API: Date Interval data type
32 * This class represents a date interval.
33 * It is a pair of UDate representing from UDate 1 to UDate 2.
36 class U_COMMON_API DateInterval
: public UObject
{
40 * Construct a DateInterval given a from date and a to date.
41 * @param fromDate The from date in date interval.
42 * @param toDate The to date in date interval.
45 DateInterval(UDate fromDate
, UDate toDate
);
51 virtual ~DateInterval();
55 * @return the from date in dateInterval.
58 inline UDate
getFromDate() const;
62 * @return the to date in dateInterval.
65 inline UDate
getToDate() const;
69 * Return the class ID for this class. This is useful only for comparing to
70 * a return value from getDynamicClassID(). For example:
72 * . Base* polymorphic_pointer = createPolymorphicObject();
73 * . if (polymorphic_pointer->getDynamicClassID() ==
74 * . derived::getStaticClassID()) ...
76 * @return The class ID for all objects of this class.
79 static UClassID U_EXPORT2
getStaticClassID(void);
82 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
83 * method is to implement a simple version of RTTI, since not all C++
84 * compilers support genuine RTTI. Polymorphic operator==() and clone()
85 * methods call this method.
87 * @return The class ID for this object. All objects of a
88 * given class have the same class ID. Objects of
89 * other classes have different class IDs.
92 virtual UClassID
getDynamicClassID(void) const;
99 DateInterval(const DateInterval
& other
);
102 * Default assignment operator
105 DateInterval
& operator=(const DateInterval
&);
109 * @return TRUE if the two DateIntervals are the same
112 virtual UBool
operator==(const DateInterval
& other
) const;
115 * Non-equality operator
116 * @return TRUE if the two DateIntervals are not the same
119 inline UBool
operator!=(const DateInterval
& other
) const;
124 * The caller owns the result and should delete it when done.
125 * @return a cloned DateInterval
128 virtual DateInterval
* clone() const;
132 * Default constructor, not implemented.
139 } ;// end class DateInterval
143 DateInterval::getFromDate() const {
149 DateInterval::getToDate() const {
155 DateInterval::operator!=(const DateInterval
& other
) const {
156 return ( !operator==(other
) );
162 #endif /* U_SHOW_CPLUSPLUS_API */