]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/unicode/tztrans.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / tztrans.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
46f4442e
A
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
340931cb
A
19#if U_SHOW_CPLUSPLUS_API
20
46f4442e
A
21#if !UCONFIG_NO_FORMATTING
22
23#include "unicode/uobject.h"
24
25U_NAMESPACE_BEGIN
26
27// Forward declaration
28class TimeZoneRule;
29
30/**
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.
729e4ab9 33 * @stable ICU 3.8
46f4442e
A
34 */
35class U_I18N_API TimeZoneTransition : public UObject {
36public:
37 /**
38 * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
39 * the transition.
40 *
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.
729e4ab9 44 * @stable ICU 3.8
46f4442e
A
45 */
46 TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to);
47
48 /**
49 * Constructs an empty <code>TimeZoneTransition</code>
729e4ab9 50 * @stable ICU 3.8
46f4442e
A
51 */
52 TimeZoneTransition();
53
54 /**
55 * Copy constructor.
56 * @param source The TimeZoneTransition object to be copied.
729e4ab9 57 * @stable ICU 3.8
46f4442e
A
58 */
59 TimeZoneTransition(const TimeZoneTransition& source);
60
61 /**
62 * Destructor.
729e4ab9 63 * @stable ICU 3.8
46f4442e
A
64 */
65 ~TimeZoneTransition();
66
67 /**
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.
729e4ab9 71 * @stable ICU 3.8
46f4442e 72 */
340931cb 73 TimeZoneTransition* clone() const;
46f4442e
A
74
75 /**
76 * Assignment operator.
77 * @param right The object to be copied.
729e4ab9 78 * @stable ICU 3.8
46f4442e
A
79 */
80 TimeZoneTransition& operator=(const TimeZoneTransition& right);
81
82 /**
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.
729e4ab9 87 * @stable ICU 3.8
46f4442e
A
88 */
89 UBool operator==(const TimeZoneTransition& that) const;
90
91 /**
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.
729e4ab9 96 * @stable ICU 3.8
46f4442e
A
97 */
98 UBool operator!=(const TimeZoneTransition& that) const;
99
100 /**
101 * Returns the time of transition in milliseconds.
102 * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
729e4ab9 103 * @stable ICU 3.8
46f4442e
A
104 */
105 UDate getTime(void) const;
106
107 /**
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.
729e4ab9 110 * @stable ICU 3.8
46f4442e
A
111 */
112 void setTime(UDate time);
113
114 /**
115 * Returns the rule used before the transition.
116 * @return The time zone rule used after the transition.
729e4ab9 117 * @stable ICU 3.8
46f4442e
A
118 */
119 const TimeZoneRule* getFrom(void) const;
120
121 /**
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.
729e4ab9 125 * @stable ICU 3.8
46f4442e
A
126 */
127 void setFrom(const TimeZoneRule& from);
128
129 /**
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.
729e4ab9 133 * @stable ICU 3.8
46f4442e
A
134 */
135 void adoptFrom(TimeZoneRule* from);
136
137 /**
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.
729e4ab9 141 * @stable ICU 3.8
46f4442e
A
142 */
143 void setTo(const TimeZoneRule& to);
144
145 /**
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.
729e4ab9 149 * @stable ICU 3.8
46f4442e
A
150 */
151 void adoptTo(TimeZoneRule* to);
152
153 /**
154 * Returns the rule used after the transition.
155 * @return The time zone rule used after the transition.
729e4ab9 156 * @stable ICU 3.8
46f4442e
A
157 */
158 const TimeZoneRule* getTo(void) const;
159
160private:
161 UDate fTime;
162 TimeZoneRule* fFrom;
163 TimeZoneRule* fTo;
164
165public:
166 /**
167 * Return the class ID for this class. This is useful only for comparing to
168 * a return value from getDynamicClassID(). For example:
169 * <pre>
170 * . Base* polymorphic_pointer = createPolymorphicObject();
171 * . if (polymorphic_pointer->getDynamicClassID() ==
172 * . erived::getStaticClassID()) ...
173 * </pre>
174 * @return The class ID for all objects of this class.
729e4ab9 175 * @stable ICU 3.8
46f4442e
A
176 */
177 static UClassID U_EXPORT2 getStaticClassID(void);
178
179 /**
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.
184 *
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.
729e4ab9 188 * @stable ICU 3.8
46f4442e
A
189 */
190 virtual UClassID getDynamicClassID(void) const;
191};
192
193U_NAMESPACE_END
194
195#endif /* #if !UCONFIG_NO_FORMATTING */
196
340931cb
A
197#endif /* U_SHOW_CPLUSPLUS_API */
198
46f4442e
A
199#endif // TZTRANS_H
200
201//eof