1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2009-2016, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
14 * \brief C API: Time zone transition classes
17 #include "unicode/utypes.h"
19 #if !UCONFIG_NO_FORMATTING
21 #include "unicode/uobject.h"
26 * A TimeZoneTransition. Use the ztrans_* API to manipulate. Create with
27 * ztrans_open*, and destroy with ztrans_close.
30 typedef struct ZTrans ZTrans
;
35 * Constructs a time zone transition with the time and the rules before/after
38 * @param time The time of transition in milliseconds since the base time.
39 * @param from The time zone rule used before the transition.
40 * @param to The time zone rule used after the transition.
42 U_CAPI ZTrans
* U_EXPORT2
43 ztrans_open(UDate time
, const void* from
, const void* to
);
46 * Constructs an empty <code>TimeZoneTransition</code>
48 U_CAPI ZTrans
* U_EXPORT2
52 * Disposes of the storage used by a ZTrans object. This function should
53 * be called exactly once for objects returned by ztrans_open*.
54 * @param trans the object to dispose of
57 ztrans_close(ZTrans
*trans
);
60 * Returns a copy of this object.
61 * @param rule the original ZRule
62 * @return the newly allocated copy of the ZRule
64 U_CAPI ZTrans
* U_EXPORT2
65 ztrans_clone(ZTrans
*trans
);
68 * Returns true if trans1 is identical to trans2
70 * @param trans1 to be checked for containment
71 * @param trans2 to be checked for containment
72 * @return true if the test condition is met
74 U_CAPI UBool U_EXPORT2
75 ztrans_equals(const ZTrans
* trans1
, const ZTrans
* trans2
);
78 * Returns the time of transition in milliseconds.
79 * param trans, the transition to use
80 * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
82 U_CAPI UDate U_EXPORT2
83 ztrans_getTime(ZTrans
* trans
);
86 * Sets the time of transition in milliseconds.
87 * param trans, the transition to use
88 * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
91 ztrans_setTime(ZTrans
* trans
, UDate time
);
94 * Returns the rule used before the transition.
95 * param trans, the transition to use
96 * @return The time zone rule used after the transition.
98 U_CAPI
void* U_EXPORT2
99 ztrans_getFrom(ZTrans
* & trans
);
102 * Sets the rule used before the transition. The caller remains
103 * responsible for deleting the TimeZoneRule object.
104 * param trans, the transition to use
105 * param trans, the transition to use
106 * @param from The time zone rule used before the transition.
108 U_CAPI
void U_EXPORT2
109 ztrans_setFrom(ZTrans
* trans
, const void* from
);
112 * Adopts the rule used before the transition. The caller must
113 * not delete the TimeZoneRule object passed in.
114 * param trans, the transition to use
115 * @param from The time zone rule used before the transition.
117 U_CAPI
void U_EXPORT2
118 ztrans_adoptFrom(ZTrans
* trans
, void* from
);
121 * Returns the rule used after the transition.
122 * param trans, the transition to use
123 * @return The time zone rule used after the transition.
125 U_CAPI
void* U_EXPORT2
126 ztrans_getTo(ZTrans
* trans
);
129 * Sets the rule used after the transition. The caller remains
130 * responsible for deleting the TimeZoneRule object.
131 * param trans, the transition to use
132 * @param to The time zone rule used after the transition.
134 U_CAPI
void U_EXPORT2
135 ztrans_setTo(ZTrans
* trans
, const void* to
);
138 * Adopts the rule used after the transition. The caller must
139 * not delete the TimeZoneRule object passed in.
140 * param trans, the transition to use
141 * @param to The time zone rule used after the transition.
143 U_CAPI
void U_EXPORT2
144 ztrans_adoptTo(ZTrans
* trans
, void* to
);
147 * Return the class ID for this class. This is useful only for comparing to
148 * a return value from getDynamicClassID(). For example:
150 * . Base* polymorphic_pointer = createPolymorphicObject();
151 * . if (polymorphic_pointer->getDynamicClassID() ==
152 * . erived::getStaticClassID()) ...
154 * param trans, the transition to use
155 * @return The class ID for all objects of this class.
157 U_CAPI UClassID U_EXPORT2
158 ztrans_getStaticClassID(ZTrans
* trans
);
161 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
162 * method is to implement a simple version of RTTI, since not all C++
163 * compilers support genuine RTTI. Polymorphic operator==() and clone()
164 * methods call this method.
166 * param trans, the transition to use
167 * @return The class ID for this object. All objects of a
168 * given class have the same class ID. Objects of
169 * other classes have different class IDs.
171 U_CAPI UClassID U_EXPORT2
172 ztrans_getDynamicClassID(ZTrans
* trans
);