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"
18 #include "unicode/uobject.h"
22 * \brief C++ API: Date Interval data type
26 #if U_SHOW_CPLUSPLUS_API
31 * This class represents a date interval.
32 * It is a pair of UDate representing from UDate 1 to UDate 2.
35 class U_COMMON_API DateInterval
: public UObject
{
39 * Construct a DateInterval given a from date and a to date.
40 * @param fromDate The from date in date interval.
41 * @param toDate The to date in date interval.
44 DateInterval(UDate fromDate
, UDate toDate
);
50 virtual ~DateInterval();
54 * @return the from date in dateInterval.
57 UDate
getFromDate() const;
61 * @return the to date in dateInterval.
64 UDate
getToDate() const;
68 * Return the class ID for this class. This is useful only for comparing to
69 * a return value from getDynamicClassID(). For example:
71 * . Base* polymorphic_pointer = createPolymorphicObject();
72 * . if (polymorphic_pointer->getDynamicClassID() ==
73 * . erived::getStaticClassID()) ...
75 * @return The class ID for all objects of this class.
78 static UClassID U_EXPORT2
getStaticClassID(void);
81 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
82 * method is to implement a simple version of RTTI, since not all C++
83 * compilers support genuine RTTI. Polymorphic operator==() and clone()
84 * methods call this method.
86 * @return The class ID for this object. All objects of a
87 * given class have the same class ID. Objects of
88 * other classes have different class IDs.
91 virtual UClassID
getDynamicClassID(void) const;
98 DateInterval(const DateInterval
& other
);
101 * Default assignment operator
104 DateInterval
& operator=(const DateInterval
&);
108 * @return TRUE if the two DateIntervals are the same
111 virtual UBool
operator==(const DateInterval
& other
) const;
114 * Non-equality operator
115 * @return TRUE if the two DateIntervals are not the same
118 UBool
operator!=(const DateInterval
& other
) const;
123 * The caller owns the result and should delete it when done.
124 * @return a cloned DateInterval
127 virtual DateInterval
* clone() const;
131 * Default constructor, not implemented.
138 } ;// end class DateInterval
142 DateInterval::getFromDate() const {
148 DateInterval::getToDate() const {
154 DateInterval::operator!=(const DateInterval
& other
) const {
155 return ( !operator==(other
) );
160 #endif // U_SHOW_CPLUSPLUS_API