2 *******************************************************************************
3 * Copyright (C) 2009-2016, 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
19 #include "unicode/uobject.h"
24 * A TimeZoneTransition. Use the ztrans_* API to manipulate. Create with
25 * ztrans_open*, and destroy with ztrans_close.
28 typedef struct ZTrans ZTrans
;
33 * Constructs a time zone transition with the time and the rules before/after
36 * @param time The time of transition in milliseconds since the base time.
37 * @param from The time zone rule used before the transition.
38 * @param to The time zone rule used after the transition.
40 U_CAPI ZTrans
* U_EXPORT2
41 ztrans_open(UDate time
, const void* from
, const void* to
);
44 * Constructs an empty <code>TimeZoneTransition</code>
46 U_CAPI ZTrans
* U_EXPORT2
50 * Disposes of the storage used by a ZTrans object. This function should
51 * be called exactly once for objects returned by ztrans_open*.
52 * @param trans the object to dispose of
55 ztrans_close(ZTrans
*trans
);
58 * Returns a copy of this object.
59 * @param rule the original ZRule
60 * @return the newly allocated copy of the ZRule
62 U_CAPI ZTrans
* U_EXPORT2
63 ztrans_clone(ZTrans
*trans
);
66 * Returns true if trans1 is identical to trans2
68 * @param trans1 to be checked for containment
69 * @param trans2 to be checked for containment
70 * @return true if the test condition is met
72 U_CAPI UBool U_EXPORT2
73 ztrans_equals(const ZTrans
* trans1
, const ZTrans
* trans2
);
76 * Returns the time of transition in milliseconds.
77 * param trans, the transition to use
78 * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
80 U_CAPI UDate U_EXPORT2
81 ztrans_getTime(ZTrans
* trans
);
84 * Sets the time of transition in milliseconds.
85 * param trans, the transition to use
86 * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
89 ztrans_setTime(ZTrans
* trans
, UDate time
);
92 * Returns the rule used before the transition.
93 * param trans, the transition to use
94 * @return The time zone rule used after the transition.
96 U_CAPI
void* U_EXPORT2
97 ztrans_getFrom(ZTrans
* & trans
);
100 * Sets the rule used before the transition. The caller remains
101 * responsible for deleting the TimeZoneRule object.
102 * param trans, the transition to use
103 * param trans, the transition to use
104 * @param from The time zone rule used before the transition.
106 U_CAPI
void U_EXPORT2
107 ztrans_setFrom(ZTrans
* trans
, const void* from
);
110 * Adopts the rule used before the transition. The caller must
111 * not delete the TimeZoneRule object passed in.
112 * param trans, the transition to use
113 * @param from The time zone rule used before the transition.
115 U_CAPI
void U_EXPORT2
116 ztrans_adoptFrom(ZTrans
* trans
, void* from
);
119 * Returns the rule used after the transition.
120 * param trans, the transition to use
121 * @return The time zone rule used after the transition.
123 U_CAPI
void* U_EXPORT2
124 ztrans_getTo(ZTrans
* trans
);
127 * Sets the rule used after the transition. The caller remains
128 * responsible for deleting the TimeZoneRule object.
129 * param trans, the transition to use
130 * @param to The time zone rule used after the transition.
132 U_CAPI
void U_EXPORT2
133 ztrans_setTo(ZTrans
* trans
, const void* to
);
136 * Adopts the rule used after the transition. The caller must
137 * not delete the TimeZoneRule object passed in.
138 * param trans, the transition to use
139 * @param to The time zone rule used after the transition.
141 U_CAPI
void U_EXPORT2
142 ztrans_adoptTo(ZTrans
* trans
, void* to
);
145 * Return the class ID for this class. This is useful only for comparing to
146 * a return value from getDynamicClassID(). For example:
148 * . Base* polymorphic_pointer = createPolymorphicObject();
149 * . if (polymorphic_pointer->getDynamicClassID() ==
150 * . erived::getStaticClassID()) ...
152 * param trans, the transition to use
153 * @return The class ID for all objects of this class.
155 U_CAPI UClassID U_EXPORT2
156 ztrans_getStaticClassID(ZTrans
* trans
);
159 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
160 * method is to implement a simple version of RTTI, since not all C++
161 * compilers support genuine RTTI. Polymorphic operator==() and clone()
162 * methods call this method.
164 * param trans, the transition to use
165 * @return The class ID for this object. All objects of a
166 * given class have the same class ID. Objects of
167 * other classes have different class IDs.
169 U_CAPI UClassID U_EXPORT2
170 ztrans_getDynamicClassID(ZTrans
* trans
);