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