2 *******************************************************************************
3 * Copyright (C) 2007-2008, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
12 * \brief C++ API: Time zone transition
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_FORMATTING
19 #include "unicode/uobject.h"
23 // Forward declaration
27 * <code>TimeZoneTransition</code> is a class representing a time zone transition.
28 * An instance has a time of transition and rules for both before and after the transition.
31 class U_I18N_API TimeZoneTransition
: public UObject
{
34 * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
37 * @param time The time of transition in milliseconds since the base time.
38 * @param from The time zone rule used before the transition.
39 * @param to The time zone rule used after the transition.
42 TimeZoneTransition(UDate time
, const TimeZoneRule
& from
, const TimeZoneRule
& to
);
45 * Constructs an empty <code>TimeZoneTransition</code>
52 * @param source The TimeZoneTransition object to be copied.
55 TimeZoneTransition(const TimeZoneTransition
& source
);
61 ~TimeZoneTransition();
64 * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
65 * should delete it when done.
66 * @return A copy of the object.
69 TimeZoneTransition
* clone(void) const;
72 * Assignment operator.
73 * @param right The object to be copied.
76 TimeZoneTransition
& operator=(const TimeZoneTransition
& right
);
79 * Return true if the given TimeZoneTransition objects are semantically equal. Objects
80 * of different subclasses are considered unequal.
81 * @param that The object to be compared with.
82 * @return true if the given TimeZoneTransition objects are semantically equal.
85 UBool
operator==(const TimeZoneTransition
& that
) const;
88 * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
89 * of different subclasses are considered unequal.
90 * @param that The object to be compared with.
91 * @return true if the given TimeZoneTransition objects are semantically unequal.
94 UBool
operator!=(const TimeZoneTransition
& that
) const;
97 * Returns the time of transition in milliseconds.
98 * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
101 UDate
getTime(void) const;
104 * Sets the time of transition in milliseconds.
105 * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
108 void setTime(UDate time
);
111 * Returns the rule used before the transition.
112 * @return The time zone rule used after the transition.
115 const TimeZoneRule
* getFrom(void) const;
118 * Sets the rule used before the transition. The caller remains
119 * responsible for deleting the <code>TimeZoneRule</code> object.
120 * @param from The time zone rule used before the transition.
123 void setFrom(const TimeZoneRule
& from
);
126 * Adopts the rule used before the transition. The caller must
127 * not delete the <code>TimeZoneRule</code> object passed in.
128 * @param from The time zone rule used before the transition.
131 void adoptFrom(TimeZoneRule
* from
);
134 * Sets the rule used after the transition. The caller remains
135 * responsible for deleting the <code>TimeZoneRule</code> object.
136 * @param to The time zone rule used after the transition.
139 void setTo(const TimeZoneRule
& to
);
142 * Adopts the rule used after the transition. The caller must
143 * not delete the <code>TimeZoneRule</code> object passed in.
144 * @param to The time zone rule used after the transition.
147 void adoptTo(TimeZoneRule
* to
);
150 * Returns the rule used after the transition.
151 * @return The time zone rule used after the transition.
154 const TimeZoneRule
* getTo(void) const;
163 * Return the class ID for this class. This is useful only for comparing to
164 * a return value from getDynamicClassID(). For example:
166 * . Base* polymorphic_pointer = createPolymorphicObject();
167 * . if (polymorphic_pointer->getDynamicClassID() ==
168 * . erived::getStaticClassID()) ...
170 * @return The class ID for all objects of this class.
173 static UClassID U_EXPORT2
getStaticClassID(void);
176 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
177 * method is to implement a simple version of RTTI, since not all C++
178 * compilers support genuine RTTI. Polymorphic operator==() and clone()
179 * methods call this method.
181 * @return The class ID for this object. All objects of a
182 * given class have the same class ID. Objects of
183 * other classes have different class IDs.
186 virtual UClassID
getDynamicClassID(void) const;
191 #endif /* #if !UCONFIG_NO_FORMATTING */