2 *******************************************************************************
3 * Copyright (C) 2009-2011, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
12 * \brief C API: Time zone transition classes
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_FORMATTING
22 * A TimeZoneTransition. Use the ztrans_* API to manipulate. Create with
23 * ztrans_open*, and destroy with ztrans_close.
26 typedef struct ZTrans ZTrans
;
31 * Constructs a time zone transition with the time and the rules before/after
34 * @param time The time of transition in milliseconds since the base time.
35 * @param from The time zone rule used before the transition.
36 * @param to The time zone rule used after the transition.
38 U_CAPI ZTrans
* U_EXPORT2
39 ztrans_open(UDate time
, const void* from
, const void* to
);
42 * Constructs an empty <code>TimeZoneTransition</code>
44 U_CAPI ZTrans
* U_EXPORT2
48 * Disposes of the storage used by a ZTrans object. This function should
49 * be called exactly once for objects returned by ztrans_open*.
50 * @param trans the object to dispose of
53 ztrans_close(ZTrans
*trans
);
56 * Returns a copy of this object.
57 * @param rule the original ZRule
58 * @return the newly allocated copy of the ZRule
60 U_CAPI ZTrans
* U_EXPORT2
61 ztrans_clone(ZTrans
*trans
);
64 * Returns true if trans1 is identical to trans2
66 * @param trans1 to be checked for containment
67 * @param trans2 to be checked for containment
68 * @return true if the test condition is met
70 U_CAPI UBool U_EXPORT2
71 ztrans_equals(const ZTrans
* trans1
, const ZTrans
* trans2
);
74 * Returns the time of transition in milliseconds.
75 * param trans, the transition to use
76 * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
78 U_CAPI UDate U_EXPORT2
79 ztrans_getTime(ZTrans
* trans
);
82 * Sets the time of transition in milliseconds.
83 * param trans, the transition to use
84 * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
87 ztrans_setTime(ZTrans
* trans
, UDate time
);
90 * Returns the rule used before the transition.
91 * param trans, the transition to use
92 * @return The time zone rule used after the transition.
94 U_CAPI
void* U_EXPORT2
95 ztrans_getFrom(ZTrans
* & trans
);
98 * Sets the rule used before the transition. The caller remains
99 * responsible for deleting the TimeZoneRule object.
100 * param trans, the transition to use
101 * param trans, the transition to use
102 * @param from The time zone rule used before the transition.
104 U_CAPI
void U_EXPORT2
105 ztrans_setFrom(ZTrans
* trans
, const void* from
);
108 * Adopts the rule used before the transition. The caller must
109 * not delete the TimeZoneRule object passed in.
110 * param trans, the transition to use
111 * @param from The time zone rule used before the transition.
113 U_CAPI
void U_EXPORT2
114 ztrans_adoptFrom(ZTrans
* trans
, void* from
);
117 * Returns the rule used after the transition.
118 * param trans, the transition to use
119 * @return The time zone rule used after the transition.
121 U_CAPI
void* U_EXPORT2
122 ztrans_getTo(ZTrans
* trans
);
125 * Sets the rule used after the transition. The caller remains
126 * responsible for deleting the TimeZoneRule object.
127 * param trans, the transition to use
128 * @param to The time zone rule used after the transition.
130 U_CAPI
void U_EXPORT2
131 ztrans_setTo(ZTrans
* trans
, const void* to
);
134 * Adopts the rule used after the transition. The caller must
135 * not delete the TimeZoneRule object passed in.
136 * param trans, the transition to use
137 * @param to The time zone rule used after the transition.
139 U_CAPI
void U_EXPORT2
140 ztrans_adoptTo(ZTrans
* trans
, void* to
);
143 * Return the class ID for this class. This is useful only for comparing to
144 * a return value from getDynamicClassID(). For example:
146 * . Base* polymorphic_pointer = createPolymorphicObject();
147 * . if (polymorphic_pointer->getDynamicClassID() ==
148 * . erived::getStaticClassID()) ...
150 * param trans, the transition to use
151 * @return The class ID for all objects of this class.
153 U_CAPI UClassID U_EXPORT2
154 ztrans_getStaticClassID(ZTrans
* trans
);
157 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
158 * method is to implement a simple version of RTTI, since not all C++
159 * compilers support genuine RTTI. Polymorphic operator==() and clone()
160 * methods call this method.
162 * param trans, the transition to use
163 * @return The class ID for this object. All objects of a
164 * given class have the same class ID. Objects of
165 * other classes have different class IDs.
167 U_CAPI UClassID U_EXPORT2
168 ztrans_getDynamicClassID(ZTrans
* trans
);