xref: /aosp_15_r20/external/icu/libicu/cts_headers/unicode/tztrans.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2007-2008, International Business Machines Corporation and         *
6*0e209d39SAndroid Build Coastguard Worker * others. All Rights Reserved.                                                *
7*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
8*0e209d39SAndroid Build Coastguard Worker */
9*0e209d39SAndroid Build Coastguard Worker #ifndef TZTRANS_H
10*0e209d39SAndroid Build Coastguard Worker #define TZTRANS_H
11*0e209d39SAndroid Build Coastguard Worker 
12*0e209d39SAndroid Build Coastguard Worker /**
13*0e209d39SAndroid Build Coastguard Worker  * \file
14*0e209d39SAndroid Build Coastguard Worker  * \brief C++ API: Time zone transition
15*0e209d39SAndroid Build Coastguard Worker  */
16*0e209d39SAndroid Build Coastguard Worker 
17*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
18*0e209d39SAndroid Build Coastguard Worker 
19*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
20*0e209d39SAndroid Build Coastguard Worker 
21*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING
22*0e209d39SAndroid Build Coastguard Worker 
23*0e209d39SAndroid Build Coastguard Worker #include "unicode/uobject.h"
24*0e209d39SAndroid Build Coastguard Worker 
25*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
26*0e209d39SAndroid Build Coastguard Worker 
27*0e209d39SAndroid Build Coastguard Worker // Forward declaration
28*0e209d39SAndroid Build Coastguard Worker class TimeZoneRule;
29*0e209d39SAndroid Build Coastguard Worker 
30*0e209d39SAndroid Build Coastguard Worker /**
31*0e209d39SAndroid Build Coastguard Worker  * <code>TimeZoneTransition</code> is a class representing a time zone transition.
32*0e209d39SAndroid Build Coastguard Worker  * An instance has a time of transition and rules for both before and after the transition.
33*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 3.8
34*0e209d39SAndroid Build Coastguard Worker  */
35*0e209d39SAndroid Build Coastguard Worker class U_I18N_API TimeZoneTransition : public UObject {
36*0e209d39SAndroid Build Coastguard Worker public:
37*0e209d39SAndroid Build Coastguard Worker     /**
38*0e209d39SAndroid Build Coastguard Worker      * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
39*0e209d39SAndroid Build Coastguard Worker      * the transition.
40*0e209d39SAndroid Build Coastguard Worker      *
41*0e209d39SAndroid Build Coastguard Worker      * @param time  The time of transition in milliseconds since the base time.
42*0e209d39SAndroid Build Coastguard Worker      * @param from  The time zone rule used before the transition.
43*0e209d39SAndroid Build Coastguard Worker      * @param to    The time zone rule used after the transition.
44*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
45*0e209d39SAndroid Build Coastguard Worker      */
46*0e209d39SAndroid Build Coastguard Worker     TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to);
47*0e209d39SAndroid Build Coastguard Worker 
48*0e209d39SAndroid Build Coastguard Worker     /**
49*0e209d39SAndroid Build Coastguard Worker      * Constructs an empty <code>TimeZoneTransition</code>
50*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
51*0e209d39SAndroid Build Coastguard Worker      */
52*0e209d39SAndroid Build Coastguard Worker     TimeZoneTransition();
53*0e209d39SAndroid Build Coastguard Worker 
54*0e209d39SAndroid Build Coastguard Worker     /**
55*0e209d39SAndroid Build Coastguard Worker      * Copy constructor.
56*0e209d39SAndroid Build Coastguard Worker      * @param source    The TimeZoneTransition object to be copied.
57*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
58*0e209d39SAndroid Build Coastguard Worker      */
59*0e209d39SAndroid Build Coastguard Worker     TimeZoneTransition(const TimeZoneTransition& source);
60*0e209d39SAndroid Build Coastguard Worker 
61*0e209d39SAndroid Build Coastguard Worker     /**
62*0e209d39SAndroid Build Coastguard Worker      * Destructor.
63*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
64*0e209d39SAndroid Build Coastguard Worker      */
65*0e209d39SAndroid Build Coastguard Worker     ~TimeZoneTransition();
66*0e209d39SAndroid Build Coastguard Worker 
67*0e209d39SAndroid Build Coastguard Worker     /**
68*0e209d39SAndroid Build Coastguard Worker      * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
69*0e209d39SAndroid Build Coastguard Worker      * should delete it when done.
70*0e209d39SAndroid Build Coastguard Worker      * @return  A copy of the object.
71*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
72*0e209d39SAndroid Build Coastguard Worker      */
73*0e209d39SAndroid Build Coastguard Worker     TimeZoneTransition* clone() const;
74*0e209d39SAndroid Build Coastguard Worker 
75*0e209d39SAndroid Build Coastguard Worker     /**
76*0e209d39SAndroid Build Coastguard Worker      * Assignment operator.
77*0e209d39SAndroid Build Coastguard Worker      * @param right The object to be copied.
78*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
79*0e209d39SAndroid Build Coastguard Worker      */
80*0e209d39SAndroid Build Coastguard Worker     TimeZoneTransition& operator=(const TimeZoneTransition& right);
81*0e209d39SAndroid Build Coastguard Worker 
82*0e209d39SAndroid Build Coastguard Worker     /**
83*0e209d39SAndroid Build Coastguard Worker      * Return true if the given TimeZoneTransition objects are semantically equal. Objects
84*0e209d39SAndroid Build Coastguard Worker      * of different subclasses are considered unequal.
85*0e209d39SAndroid Build Coastguard Worker      * @param that  The object to be compared with.
86*0e209d39SAndroid Build Coastguard Worker      * @return  true if the given TimeZoneTransition objects are semantically equal.
87*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
88*0e209d39SAndroid Build Coastguard Worker      */
89*0e209d39SAndroid Build Coastguard Worker     bool operator==(const TimeZoneTransition& that) const;
90*0e209d39SAndroid Build Coastguard Worker 
91*0e209d39SAndroid Build Coastguard Worker     /**
92*0e209d39SAndroid Build Coastguard Worker      * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
93*0e209d39SAndroid Build Coastguard Worker      * of different subclasses are considered unequal.
94*0e209d39SAndroid Build Coastguard Worker      * @param that  The object to be compared with.
95*0e209d39SAndroid Build Coastguard Worker      * @return  true if the given TimeZoneTransition objects are semantically unequal.
96*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
97*0e209d39SAndroid Build Coastguard Worker      */
98*0e209d39SAndroid Build Coastguard Worker     bool operator!=(const TimeZoneTransition& that) const;
99*0e209d39SAndroid Build Coastguard Worker 
100*0e209d39SAndroid Build Coastguard Worker     /**
101*0e209d39SAndroid Build Coastguard Worker      * Returns the time of transition in milliseconds.
102*0e209d39SAndroid Build Coastguard Worker      * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
103*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
104*0e209d39SAndroid Build Coastguard Worker      */
105*0e209d39SAndroid Build Coastguard Worker     UDate getTime() const;
106*0e209d39SAndroid Build Coastguard Worker 
107*0e209d39SAndroid Build Coastguard Worker     /**
108*0e209d39SAndroid Build Coastguard Worker      * Sets the time of transition in milliseconds.
109*0e209d39SAndroid Build Coastguard Worker      * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
110*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
111*0e209d39SAndroid Build Coastguard Worker      */
112*0e209d39SAndroid Build Coastguard Worker     void setTime(UDate time);
113*0e209d39SAndroid Build Coastguard Worker 
114*0e209d39SAndroid Build Coastguard Worker     /**
115*0e209d39SAndroid Build Coastguard Worker      * Returns the rule used before the transition.
116*0e209d39SAndroid Build Coastguard Worker      * @return The time zone rule used after the transition.
117*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
118*0e209d39SAndroid Build Coastguard Worker      */
119*0e209d39SAndroid Build Coastguard Worker     const TimeZoneRule* getFrom() const;
120*0e209d39SAndroid Build Coastguard Worker 
121*0e209d39SAndroid Build Coastguard Worker     /**
122*0e209d39SAndroid Build Coastguard Worker      * Sets the rule used before the transition.  The caller remains
123*0e209d39SAndroid Build Coastguard Worker      * responsible for deleting the <code>TimeZoneRule</code> object.
124*0e209d39SAndroid Build Coastguard Worker      * @param from The time zone rule used before the transition.
125*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
126*0e209d39SAndroid Build Coastguard Worker      */
127*0e209d39SAndroid Build Coastguard Worker     void setFrom(const TimeZoneRule& from);
128*0e209d39SAndroid Build Coastguard Worker 
129*0e209d39SAndroid Build Coastguard Worker     /**
130*0e209d39SAndroid Build Coastguard Worker      * Adopts the rule used before the transition.  The caller must
131*0e209d39SAndroid Build Coastguard Worker      * not delete the <code>TimeZoneRule</code> object passed in.
132*0e209d39SAndroid Build Coastguard Worker      * @param from The time zone rule used before the transition.
133*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
134*0e209d39SAndroid Build Coastguard Worker      */
135*0e209d39SAndroid Build Coastguard Worker     void adoptFrom(TimeZoneRule* from);
136*0e209d39SAndroid Build Coastguard Worker 
137*0e209d39SAndroid Build Coastguard Worker     /**
138*0e209d39SAndroid Build Coastguard Worker      * Sets the rule used after the transition.  The caller remains
139*0e209d39SAndroid Build Coastguard Worker      * responsible for deleting the <code>TimeZoneRule</code> object.
140*0e209d39SAndroid Build Coastguard Worker      * @param to The time zone rule used after the transition.
141*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
142*0e209d39SAndroid Build Coastguard Worker      */
143*0e209d39SAndroid Build Coastguard Worker     void setTo(const TimeZoneRule& to);
144*0e209d39SAndroid Build Coastguard Worker 
145*0e209d39SAndroid Build Coastguard Worker     /**
146*0e209d39SAndroid Build Coastguard Worker      * Adopts the rule used after the transition.  The caller must
147*0e209d39SAndroid Build Coastguard Worker      * not delete the <code>TimeZoneRule</code> object passed in.
148*0e209d39SAndroid Build Coastguard Worker      * @param to The time zone rule used after the transition.
149*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
150*0e209d39SAndroid Build Coastguard Worker      */
151*0e209d39SAndroid Build Coastguard Worker     void adoptTo(TimeZoneRule* to);
152*0e209d39SAndroid Build Coastguard Worker 
153*0e209d39SAndroid Build Coastguard Worker     /**
154*0e209d39SAndroid Build Coastguard Worker      * Returns the rule used after the transition.
155*0e209d39SAndroid Build Coastguard Worker      * @return The time zone rule used after the transition.
156*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
157*0e209d39SAndroid Build Coastguard Worker      */
158*0e209d39SAndroid Build Coastguard Worker     const TimeZoneRule* getTo() const;
159*0e209d39SAndroid Build Coastguard Worker 
160*0e209d39SAndroid Build Coastguard Worker private:
161*0e209d39SAndroid Build Coastguard Worker     UDate   fTime;
162*0e209d39SAndroid Build Coastguard Worker     TimeZoneRule*   fFrom;
163*0e209d39SAndroid Build Coastguard Worker     TimeZoneRule*   fTo;
164*0e209d39SAndroid Build Coastguard Worker 
165*0e209d39SAndroid Build Coastguard Worker public:
166*0e209d39SAndroid Build Coastguard Worker     /**
167*0e209d39SAndroid Build Coastguard Worker      * Return the class ID for this class. This is useful only for comparing to
168*0e209d39SAndroid Build Coastguard Worker      * a return value from getDynamicClassID(). For example:
169*0e209d39SAndroid Build Coastguard Worker      * <pre>
170*0e209d39SAndroid Build Coastguard Worker      * .   Base* polymorphic_pointer = createPolymorphicObject();
171*0e209d39SAndroid Build Coastguard Worker      * .   if (polymorphic_pointer->getDynamicClassID() ==
172*0e209d39SAndroid Build Coastguard Worker      * .       erived::getStaticClassID()) ...
173*0e209d39SAndroid Build Coastguard Worker      * </pre>
174*0e209d39SAndroid Build Coastguard Worker      * @return          The class ID for all objects of this class.
175*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
176*0e209d39SAndroid Build Coastguard Worker      */
177*0e209d39SAndroid Build Coastguard Worker     static UClassID U_EXPORT2 getStaticClassID();
178*0e209d39SAndroid Build Coastguard Worker 
179*0e209d39SAndroid Build Coastguard Worker     /**
180*0e209d39SAndroid Build Coastguard Worker      * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
181*0e209d39SAndroid Build Coastguard Worker      * method is to implement a simple version of RTTI, since not all C++
182*0e209d39SAndroid Build Coastguard Worker      * compilers support genuine RTTI. Polymorphic operator==() and clone()
183*0e209d39SAndroid Build Coastguard Worker      * methods call this method.
184*0e209d39SAndroid Build Coastguard Worker      *
185*0e209d39SAndroid Build Coastguard Worker      * @return          The class ID for this object. All objects of a
186*0e209d39SAndroid Build Coastguard Worker      *                  given class have the same class ID.  Objects of
187*0e209d39SAndroid Build Coastguard Worker      *                  other classes have different class IDs.
188*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 3.8
189*0e209d39SAndroid Build Coastguard Worker      */
190*0e209d39SAndroid Build Coastguard Worker     virtual UClassID getDynamicClassID() const override;
191*0e209d39SAndroid Build Coastguard Worker };
192*0e209d39SAndroid Build Coastguard Worker 
193*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
194*0e209d39SAndroid Build Coastguard Worker 
195*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */
196*0e209d39SAndroid Build Coastguard Worker 
197*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */
198*0e209d39SAndroid Build Coastguard Worker 
199*0e209d39SAndroid Build Coastguard Worker #endif // TZTRANS_H
200*0e209d39SAndroid Build Coastguard Worker 
201*0e209d39SAndroid Build Coastguard Worker //eof
202