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