1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2007-2008, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
14 * \brief C++ API: Time zone transition
17 #include "unicode/utypes.h"
19 #if U_SHOW_CPLUSPLUS_API
21 #if !UCONFIG_NO_FORMATTING
23 #include "unicode/uobject.h"
27 // Forward declaration
31 * <code>TimeZoneTransition</code> is a class representing a time zone transition.
32 * An instance has a time of transition and rules for both before and after the transition.
35 class U_I18N_API TimeZoneTransition
: public UObject
{
38 * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
41 * @param time The time of transition in milliseconds since the base time.
42 * @param from The time zone rule used before the transition.
43 * @param to The time zone rule used after the transition.
46 TimeZoneTransition(UDate time
, const TimeZoneRule
& from
, const TimeZoneRule
& to
);
49 * Constructs an empty <code>TimeZoneTransition</code>
56 * @param source The TimeZoneTransition object to be copied.
59 TimeZoneTransition(const TimeZoneTransition
& source
);
65 ~TimeZoneTransition();
68 * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
69 * should delete it when done.
70 * @return A copy of the object.
73 TimeZoneTransition
* clone() const;
76 * Assignment operator.
77 * @param right The object to be copied.
80 TimeZoneTransition
& operator=(const TimeZoneTransition
& right
);
83 * Return true if the given TimeZoneTransition objects are semantically equal. Objects
84 * of different subclasses are considered unequal.
85 * @param that The object to be compared with.
86 * @return true if the given TimeZoneTransition objects are semantically equal.
89 UBool
operator==(const TimeZoneTransition
& that
) const;
92 * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
93 * of different subclasses are considered unequal.
94 * @param that The object to be compared with.
95 * @return true if the given TimeZoneTransition objects are semantically unequal.
98 UBool
operator!=(const TimeZoneTransition
& that
) const;
101 * Returns the time of transition in milliseconds.
102 * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
105 UDate
getTime(void) const;
108 * Sets the time of transition in milliseconds.
109 * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
112 void setTime(UDate time
);
115 * Returns the rule used before the transition.
116 * @return The time zone rule used after the transition.
119 const TimeZoneRule
* getFrom(void) const;
122 * Sets the rule used before the transition. The caller remains
123 * responsible for deleting the <code>TimeZoneRule</code> object.
124 * @param from The time zone rule used before the transition.
127 void setFrom(const TimeZoneRule
& from
);
130 * Adopts the rule used before the transition. The caller must
131 * not delete the <code>TimeZoneRule</code> object passed in.
132 * @param from The time zone rule used before the transition.
135 void adoptFrom(TimeZoneRule
* from
);
138 * Sets the rule used after the transition. The caller remains
139 * responsible for deleting the <code>TimeZoneRule</code> object.
140 * @param to The time zone rule used after the transition.
143 void setTo(const TimeZoneRule
& to
);
146 * Adopts the rule used after the transition. The caller must
147 * not delete the <code>TimeZoneRule</code> object passed in.
148 * @param to The time zone rule used after the transition.
151 void adoptTo(TimeZoneRule
* to
);
154 * Returns the rule used after the transition.
155 * @return The time zone rule used after the transition.
158 const TimeZoneRule
* getTo(void) const;
167 * Return the class ID for this class. This is useful only for comparing to
168 * a return value from getDynamicClassID(). For example:
170 * . Base* polymorphic_pointer = createPolymorphicObject();
171 * . if (polymorphic_pointer->getDynamicClassID() ==
172 * . erived::getStaticClassID()) ...
174 * @return The class ID for all objects of this class.
177 static UClassID U_EXPORT2
getStaticClassID(void);
180 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
181 * method is to implement a simple version of RTTI, since not all C++
182 * compilers support genuine RTTI. Polymorphic operator==() and clone()
183 * methods call this method.
185 * @return The class ID for this object. All objects of a
186 * given class have the same class ID. Objects of
187 * other classes have different class IDs.
190 virtual UClassID
getDynamicClassID(void) const;
195 #endif /* #if !UCONFIG_NO_FORMATTING */
197 #endif /* U_SHOW_CPLUSPLUS_API */