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 !UCONFIG_NO_FORMATTING
21 #include "unicode/uobject.h"
23 #if U_SHOW_CPLUSPLUS_API
26 // Forward declaration
30 * <code>TimeZoneTransition</code> is a class representing a time zone transition.
31 * An instance has a time of transition and rules for both before and after the transition.
34 class U_I18N_API TimeZoneTransition
: public UObject
{
37 * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
40 * @param time The time of transition in milliseconds since the base time.
41 * @param from The time zone rule used before the transition.
42 * @param to The time zone rule used after the transition.
45 TimeZoneTransition(UDate time
, const TimeZoneRule
& from
, const TimeZoneRule
& to
);
48 * Constructs an empty <code>TimeZoneTransition</code>
55 * @param source The TimeZoneTransition object to be copied.
58 TimeZoneTransition(const TimeZoneTransition
& source
);
64 ~TimeZoneTransition();
67 * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
68 * should delete it when done.
69 * @return A copy of the object.
72 TimeZoneTransition
* clone(void) const;
75 * Assignment operator.
76 * @param right The object to be copied.
79 TimeZoneTransition
& operator=(const TimeZoneTransition
& right
);
82 * Return true if the given TimeZoneTransition objects are semantically equal. Objects
83 * of different subclasses are considered unequal.
84 * @param that The object to be compared with.
85 * @return true if the given TimeZoneTransition objects are semantically equal.
88 UBool
operator==(const TimeZoneTransition
& that
) const;
91 * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
92 * of different subclasses are considered unequal.
93 * @param that The object to be compared with.
94 * @return true if the given TimeZoneTransition objects are semantically unequal.
97 UBool
operator!=(const TimeZoneTransition
& that
) const;
100 * Returns the time of transition in milliseconds.
101 * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
104 UDate
getTime(void) const;
107 * Sets the time of transition in milliseconds.
108 * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
111 void setTime(UDate time
);
114 * Returns the rule used before the transition.
115 * @return The time zone rule used after the transition.
118 const TimeZoneRule
* getFrom(void) const;
121 * Sets the rule used before the transition. The caller remains
122 * responsible for deleting the <code>TimeZoneRule</code> object.
123 * @param from The time zone rule used before the transition.
126 void setFrom(const TimeZoneRule
& from
);
129 * Adopts the rule used before the transition. The caller must
130 * not delete the <code>TimeZoneRule</code> object passed in.
131 * @param from The time zone rule used before the transition.
134 void adoptFrom(TimeZoneRule
* from
);
137 * Sets the rule used after the transition. The caller remains
138 * responsible for deleting the <code>TimeZoneRule</code> object.
139 * @param to The time zone rule used after the transition.
142 void setTo(const TimeZoneRule
& to
);
145 * Adopts the rule used after the transition. The caller must
146 * not delete the <code>TimeZoneRule</code> object passed in.
147 * @param to The time zone rule used after the transition.
150 void adoptTo(TimeZoneRule
* to
);
153 * Returns the rule used after the transition.
154 * @return The time zone rule used after the transition.
157 const TimeZoneRule
* getTo(void) const;
166 * Return the class ID for this class. This is useful only for comparing to
167 * a return value from getDynamicClassID(). For example:
169 * . Base* polymorphic_pointer = createPolymorphicObject();
170 * . if (polymorphic_pointer->getDynamicClassID() ==
171 * . erived::getStaticClassID()) ...
173 * @return The class ID for all objects of this class.
176 static UClassID U_EXPORT2
getStaticClassID(void);
179 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
180 * method is to implement a simple version of RTTI, since not all C++
181 * compilers support genuine RTTI. Polymorphic operator==() and clone()
182 * methods call this method.
184 * @return The class ID for this object. All objects of a
185 * given class have the same class ID. Objects of
186 * other classes have different class IDs.
189 virtual UClassID
getDynamicClassID(void) const;
193 #endif // U_SHOW_CPLUSPLUS_API
195 #endif /* #if !UCONFIG_NO_FORMATTING */