2 *******************************************************************************
3 * Copyright (C) 2009-2010, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
12 * \brief C API: Time zone rule classes
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_FORMATTING
22 * A TimeZoneRule. Use the zrule_* API to manipulate. Create with
23 * zrule_open*, and destroy with zrule_close.
27 typedef struct ZRule ZRule
;
30 * An InitialTimeZoneRule. Use the izrule_* API to manipulate. Create with
31 * izrule_open*, and destroy with izrule_close.
35 typedef struct IZRule IZRule
;
38 * An AnnualTimeZoneRule. Use the azrule_* API to manipulate. Create with
39 * azrule_open*, and destroy with azrule_close.
43 typedef struct AZRule AZRule
;
47 /*********************************************************************
49 *********************************************************************/
52 * Disposes of the storage used by a ZRule object. This function should
53 * be called exactly once for objects returned by zrule_open*.
54 * @param set the object to dispose of
57 U_DRAFT
void U_EXPORT2
58 zrule_close(ZRule
* rule
);
61 * Returns true if rule1 is identical to rule2
63 * @param rule1 to be checked for containment
64 * @param rule2 to be checked for containment
65 * @return true if the test condition is met
68 U_DRAFT UBool U_EXPORT2
69 zrule_equals(const ZRule
* rule1
, const ZRule
* rule2
);
72 * Fills in "name" with the name of this time zone.
73 * @param rule, the Zrule to use
74 * @param name Receives the name of this time zone.
75 * @param nameLength, length of the returned name
78 U_DRAFT
void U_EXPORT2
79 zrule_getName(ZRule
* rule
, UChar
* name
, int32_t nameLength
);
82 * Gets the standard time offset.
83 * @param rule, the Zrule to use
84 * @return The standard time offset from UTC in milliseconds.
87 U_DRAFT
int32_t U_EXPORT2
88 zrule_getRawOffset(ZRule
* rule
);
91 * Gets the amount of daylight saving delta time from the standard time.
92 * @param rule, the Zrule to use
93 * @return The amount of daylight saving offset used by this rule
97 U_DRAFT
int32_t U_EXPORT2
98 zrule_getDSTSavings(ZRule
* rule
);
101 * Returns if this rule represents the same rule and offsets as another.
102 * When two ZRule objects differ only its names, this method
104 * @param rule1 to be checked for containment
105 * @param rule2 to be checked for containment
106 * @return true if the other <code>TimeZoneRule</code> is the same as this one.
109 U_DRAFT UBool U_EXPORT2
110 zrule_isEquivalentTo(ZRule
* rule1
, ZRule
* rule2
);
112 /*********************************************************************
114 *********************************************************************/
117 * Constructs an IZRule with the name, the GMT offset of its
118 * standard time and the amount of daylight saving offset adjustment.
119 * @param name The time zone name.
120 * @param nameLength The length of the time zone name.
121 * @param rawOffset The UTC offset of its standard time in milliseconds.
122 * @param dstSavings The amount of daylight saving offset adjustment in milliseconds.
123 * If this ia a rule for standard time, the value of this argument is 0.
126 U_DRAFT IZRule
* U_EXPORT2
127 izrule_open(const UChar
* name
, int32_t nameLength
, int32_t rawOffset
, int32_t dstSavings
);
130 * Disposes of the storage used by a IZRule object. This function should
131 * be called exactly once for objects returned by izrule_open*.
132 * @param set the object to dispose of
135 U_DRAFT
void U_EXPORT2
136 izrule_close(IZRule
* rule
);
139 * Returns a copy of this object.
140 * @param rule the original IZRule
141 * @return the newly allocated copy of the IZRule
144 U_DRAFT IZRule
* U_EXPORT2
145 izrule_clone(IZRule
*rule
);
148 * Returns true if rule1 is identical to rule2
150 * @param rule1 to be checked for containment
151 * @param rule2 to be checked for containment
152 * @return true if the test condition is met
155 U_DRAFT UBool U_EXPORT2
156 izrule_equals(const IZRule
* rule1
, const IZRule
* rule2
);
159 * Fills in "name" with the name of this time zone.
160 * @param rule, the IZrule to use
161 * @param name Receives the name of this time zone.
162 * @param nameLength, length of the returned name
165 U_DRAFT
void U_EXPORT2
166 izrule_getName(IZRule
* rule
, UChar
* & name
, int32_t & nameLength
);
169 * Gets the standard time offset.
170 * @param rule, the IZrule to use
171 * @return The standard time offset from UTC in milliseconds.
174 U_DRAFT
int32_t U_EXPORT2
175 izrule_getRawOffset(IZRule
* rule
);
178 * Gets the amount of daylight saving delta time from the standard time.
179 * @param rule, the IZrule to use
180 * @return The amount of daylight saving offset used by this rule
184 U_DRAFT
int32_t U_EXPORT2
185 izrule_getDSTSavings(IZRule
* rule
);
188 * Returns if this rule represents the same rule and offsets as another.
189 * When two IZRule objects differ only its names, this method
191 * @param rule1 to be checked for containment
192 * @param rule2 to be checked for containment
193 * @return true if the other <code>TimeZoneRule</code> is the same as this one.
196 U_DRAFT UBool U_EXPORT2
197 izrule_isEquivalentTo(IZRule
* rule1
, IZRule
* rule2
);
200 * Gets the very first time when this rule takes effect.
201 * @param rule The IZrule to use
202 * @param prevRawOffset The standard time offset from UTC before this rule
203 * takes effect in milliseconds.
204 * @param prevDSTSavings The amount of daylight saving offset from the
206 * @param result Receives the very first time when this rule takes effect.
207 * @return true if the start time is available. When false is returned, output parameter
208 * "result" is unchanged.
211 U_DRAFT UBool U_EXPORT2
212 izrule_getFirstStart(IZRule
* rule
, int32_t prevRawOffset
, int32_t prevDSTSavings
,
216 * Gets the final time when this rule takes effect.
217 * @param rule The IZrule to use
218 * @param prevRawOffset The standard time offset from UTC before this rule
219 * takes effect in milliseconds.
220 * @param prevDSTSavings The amount of daylight saving offset from the
222 * @param result Receives the final time when this rule takes effect.
223 * @return true if the start time is available. When false is returned, output parameter
224 * "result" is unchanged.
227 U_DRAFT UBool U_EXPORT2
228 izrule_getFinalStart(IZRule
* rule
, int32_t prevRawOffset
, int32_t prevDSTSavings
,
232 * Gets the first time when this rule takes effect after the specified time.
233 * @param rule The IZrule to use
234 * @param base The first start time after this base time will be returned.
235 * @param prevRawOffset The standard time offset from UTC before this rule
236 * takes effect in milliseconds.
237 * @param prevDSTSavings The amount of daylight saving offset from the
239 * @param inclusive Whether the base time is inclusive or not.
240 * @param result Receives The first time when this rule takes effect after
241 * the specified base time.
242 * @return true if the start time is available. When false is returned, output parameter
243 * "result" is unchanged.
246 U_DRAFT UBool U_EXPORT2
247 izrule_getNextStart(IZRule
* rule
, UDate base
, int32_t prevRawOffset
,
248 int32_t prevDSTSavings
, UBool inclusive
, UDate
& result
);
251 * Gets the most recent time when this rule takes effect before the specified time.
252 * @param rule The IZrule to use
253 * @param base The most recent time before this base time will be returned.
254 * @param prevRawOffset The standard time offset from UTC before this rule
255 * takes effect in milliseconds.
256 * @param prevDSTSavings The amount of daylight saving offset from the
258 * @param inclusive Whether the base time is inclusive or not.
259 * @param result Receives The most recent time when this rule takes effect before
260 * the specified base time.
261 * @return true if the start time is available. When false is returned, output parameter
262 * "result" is unchanged.
265 U_DRAFT UBool U_EXPORT2
266 izrule_getPreviousStart(IZRule
* rule
, UDate base
, int32_t prevRawOffset
,
267 int32_t prevDSTSavings
, UBool inclusive
, UDate
& result
);
271 * Return the class ID for this class. This is useful only for comparing to
272 * a return value from getDynamicClassID(). For example:
274 * . Base* polymorphic_pointer = createPolymorphicObject();
275 * . if (polymorphic_pointer->getDynamicClassID() ==
276 * . erived::getStaticClassID()) ...
278 * @param rule The IZrule to use
279 * @return The class ID for all objects of this class.
282 U_DRAFT UClassID U_EXPORT2
283 izrule_getStaticClassID(IZRule
* rule
);
286 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
287 * method is to implement a simple version of RTTI, since not all C++
288 * compilers support genuine RTTI. Polymorphic operator==() and clone()
289 * methods call this method.
291 * @param rule The IZrule to use
292 * @return The class ID for this object. All objects of a
293 * given class have the same class ID. Objects of
294 * other classes have different class IDs.
297 U_DRAFT UClassID U_EXPORT2
298 izrule_getDynamicClassID(IZRule
* rule
);