]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/vzone.h
ICU-511.35.tar.gz
[apple/icu.git] / icuSources / i18n / vzone.h
CommitLineData
729e4ab9
A
1/*
2*******************************************************************************
4388f060
A
3* Copyright (C) 2009-2011, International Business Machines Corporation and
4* others. All Rights Reserved.
729e4ab9
A
5*******************************************************************************
6*/
7
8/**
9* \file
10* \brief C API: RFC2445 VTIMEZONE support
11*
12* <p>This is a C wrapper around the C++ VTimeZone class.</p>
13*/
14
15#ifndef __VZONE_H
16#define __VZONE_H
17
18#include "unicode/utypes.h"
19
20#if !UCONFIG_NO_FORMATTING
21
22#include "ztrans.h"
23
24#ifndef UCNV_H
25struct VZone;
26/**
27 * A UnicodeSet. Use the vzone_* API to manipulate. Create with
28 * vzone_open*, and destroy with vzone_close.
729e4ab9
A
29 */
30typedef struct VZone VZone;
31#endif
32
33/*********************************************************************
34 * VZone API
35 *********************************************************************/
36
37/**
38 * Creates a vzone from the given time zone ID.
39 * @param ID The time zone ID, such as America/New_York
40 * @param idLength, length of the ID parameter
41 * @return A vzone object initialized by the time zone ID,
42 * or NULL when the ID is unknown.
729e4ab9 43 */
4388f060 44U_CAPI VZone* U_EXPORT2
729e4ab9 45vzone_openID(const UChar* ID, int32_t idLength);
4388f060 46
729e4ab9
A
47/**
48 * Create a vzone instance by RFC2445 VTIMEZONE data
49 * @param vtzdata The string including VTIMEZONE data block
50 * @param vtzdataLength, length of the vtzdata
51 * @param status Output param to filled in with a success or an error.
52 * @return A vzone initialized by the VTIMEZONE data or
53 * NULL if failed to load the rule from the VTIMEZONE data.
729e4ab9 54 */
4388f060 55U_CAPI VZone* U_EXPORT2
729e4ab9
A
56vzone_openData(const UChar* vtzdata, int32_t vtzdataLength, UErrorCode& status);
57
58/**
59 * Disposes of the storage used by a VZone object. This function should
60 * be called exactly once for objects returned by vzone_open*.
61 * @param set the object to dispose of
729e4ab9 62 */
4388f060 63U_CAPI void U_EXPORT2
729e4ab9
A
64vzone_close(VZone* zone);
65
66/**
67 * Returns a copy of this object.
68 * @param zone the original vzone
69 * @return the newly allocated copy of the vzone
729e4ab9 70 */
4388f060 71U_CAPI VZone* U_EXPORT2
729e4ab9
A
72vzone_clone(const VZone *zone);
73
74/**
75 * Returns true if zone1 is identical to zone2
76 * and vis versa.
77 * @param zone1 to be checked for containment
78 * @param zone2 to be checked for containment
79 * @return true if the test condition is met
729e4ab9 80 */
4388f060 81U_CAPI UBool U_EXPORT2
729e4ab9
A
82vzone_equals(const VZone* zone1, const VZone* zone2);
83
84/**
85 * Gets the RFC2445 TZURL property value. When a vzone instance was
86 * created from VTIMEZONE data, the initial value is set by the TZURL
87 * property value in the data. Otherwise, the initial value is not set.
88 * @param zone, the vzone to use
89 * @param url Receives the RFC2445 TZURL property value.
90 * @param urlLength, length of the url
91 * @return TRUE if TZURL attribute is available and value is set.
729e4ab9 92 */
4388f060 93U_CAPI UBool U_EXPORT2
729e4ab9
A
94vzone_getTZURL(VZone* zone, UChar* & url, int32_t & urlLength);
95
96/**
97 * Sets the RFC2445 TZURL property value.
98 * @param zone, the vzone to use
99 * @param url The TZURL property value.
100 * @param urlLength, length of the url
729e4ab9 101 */
4388f060 102U_CAPI void U_EXPORT2
729e4ab9
A
103vzone_setTZURL(VZone* zone, UChar* url, int32_t urlLength);
104
105/**
106 * Gets the RFC2445 LAST-MODIFIED property value. When a vzone instance
107 * was created from VTIMEZONE data, the initial value is set by the
108 * LAST-MODIFIED property value in the data. Otherwise, the initial value
109 * is not set.
110 * @param zone, the vzone to use
111 * @param lastModified Receives the last modified date.
112 * @return TRUE if lastModified attribute is available and value is set.
729e4ab9 113 */
4388f060 114U_CAPI UBool U_EXPORT2
729e4ab9
A
115vzone_getLastModified(VZone* zone, UDate& lastModified);
116
117/**
118 * Sets the RFC2445 LAST-MODIFIED property value.
119 * @param zone, the vzone to use
120 * @param lastModified The LAST-MODIFIED date.
729e4ab9 121 */
4388f060 122U_CAPI void U_EXPORT2
729e4ab9
A
123vzone_setLastModified(VZone* zone, UDate lastModified);
124
125/**
126 * Writes RFC2445 VTIMEZONE data for this time zone
127 * @param zone, the vzone to use
128 * @param result Output param to filled in with the VTIMEZONE data.
129 * @param resultLength, length of the result output
130 * @param status Output param to filled in with a success or an error.
729e4ab9 131 */
4388f060 132U_CAPI void U_EXPORT2
729e4ab9
A
133vzone_write(VZone* zone, UChar* & result, int32_t & resultLength, UErrorCode& status);
134
135/**
136 * Writes RFC2445 VTIMEZONE data for this time zone applicalbe
137 * for dates after the specified start time.
138 * @param zone, the vzone to use
139 * @param start The start date.
140 * @param result Output param to filled in with the VTIMEZONE data.
141 * @param resultLength, length of the result output
142 * @param status Output param to filled in with a success or an error.
729e4ab9 143 */
4388f060 144U_CAPI void U_EXPORT2
729e4ab9
A
145vzone_writeFromStart(VZone* zone, UDate start, UChar* & result, int32_t & resultLength, UErrorCode& status);
146
147/**
148 * Writes RFC2445 VTIMEZONE data applicalbe for the specified date.
149 * Some common iCalendar implementations can only handle a single time
150 * zone property or a pair of standard and daylight time properties using
151 * BYDAY rule with day of week (such as BYDAY=1SUN). This method produce
152 * the VTIMEZONE data which can be handled these implementations. The rules
153 * produced by this method can be used only for calculating time zone offset
154 * around the specified date.
155 * @param zone, the vzone to use
156 * @param time The date used for rule extraction.
157 * @param result Output param to filled in with the VTIMEZONE data.
158 * @param status Output param to filled in with a success or an error.
729e4ab9 159 */
4388f060 160U_CAPI void U_EXPORT2
729e4ab9
A
161vzone_writeSimple(VZone* zone, UDate time, UChar* & result, int32_t & resultLength, UErrorCode& status);
162
163/**
164 * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
165 * to GMT to get local time in this time zone, taking daylight savings time into
166 * account) as of a particular reference date. The reference date is used to determine
167 * whether daylight savings time is in effect and needs to be figured into the offset
168 * that is returned (in other words, what is the adjusted GMT offset in this time zone
169 * at this particular date and time?). For the time zones produced by createTimeZone(),
170 * the reference data is specified according to the Gregorian calendar, and the date
171 * and time fields are local standard time.
172 *
173 * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
174 * which returns both the raw and the DST offset for a given time. This method
175 * is retained only for backward compatibility.
176 *
177 * @param zone, the vzone to use
178 * @param era The reference date's era
179 * @param year The reference date's year
180 * @param month The reference date's month (0-based; 0 is January)
181 * @param day The reference date's day-in-month (1-based)
182 * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
183 * @param millis The reference date's milliseconds in day, local standard time
184 * @param status Output param to filled in with a success or an error.
185 * @return The offset in milliseconds to add to GMT to get local time.
729e4ab9 186 */
4388f060 187U_CAPI int32_t U_EXPORT2
729e4ab9
A
188vzone_getOffset(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
189 uint8_t dayOfWeek, int32_t millis, UErrorCode& status);
190
191/**
192 * Gets the time zone offset, for current date, modified in case of
193 * daylight savings. This is the offset to add *to* UTC to get local time.
194 *
195 * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
196 * which returns both the raw and the DST offset for a given time. This method
197 * is retained only for backward compatibility.
198 *
199 * @param zone, the vzone to use
200 * @param era The reference date's era
201 * @param year The reference date's year
202 * @param month The reference date's month (0-based; 0 is January)
203 * @param day The reference date's day-in-month (1-based)
204 * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
205 * @param millis The reference date's milliseconds in day, local standard time
206 * @param monthLength The length of the given month in days.
207 * @param status Output param to filled in with a success or an error.
208 * @return The offset in milliseconds to add to GMT to get local time.
729e4ab9 209 */
4388f060 210U_CAPI int32_t U_EXPORT2
729e4ab9
A
211vzone_getOffset2(VZone* zone, uint8_t era, int32_t year, int32_t month, int32_t day,
212 uint8_t dayOfWeek, int32_t millis,
213 int32_t monthLength, UErrorCode& status);
214
215/**
216 * Returns the time zone raw and GMT offset for the given moment
217 * in time. Upon return, local-millis = GMT-millis + rawOffset +
218 * dstOffset. All computations are performed in the proleptic
219 * Gregorian calendar. The default implementation in the TimeZone
220 * class delegates to the 8-argument getOffset().
221 *
222 * @param zone, the vzone to use
223 * @param date moment in time for which to return offsets, in
224 * units of milliseconds from January 1, 1970 0:00 GMT, either GMT
225 * time or local wall time, depending on `local'.
226 * @param local if true, `date' is local wall time; otherwise it
227 * is in GMT time.
228 * @param rawOffset output parameter to receive the raw offset, that
229 * is, the offset not including DST adjustments
230 * @param dstOffset output parameter to receive the DST offset,
231 * that is, the offset to be added to `rawOffset' to obtain the
232 * total offset between local and GMT time. If DST is not in
233 * effect, this value is zero; otherwise it is a positive value,
234 * typically one hour.
235 * @param ec input-output error code
729e4ab9 236 */
4388f060 237U_CAPI void U_EXPORT2
729e4ab9
A
238vzone_getOffset3(VZone* zone, UDate date, UBool local, int32_t& rawOffset,
239 int32_t& dstOffset, UErrorCode& ec);
240
241/**
242 * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
243 * to GMT to get local time, before taking daylight savings time into account).
244 *
245 * @param zone, the vzone to use
246 * @param offsetMillis The new raw GMT offset for this time zone.
729e4ab9 247 */
4388f060 248U_CAPI void U_EXPORT2
729e4ab9
A
249vzone_setRawOffset(VZone* zone, int32_t offsetMillis);
250
251/**
252 * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
253 * to GMT to get local time, before taking daylight savings time into account).
254 *
255 * @param zone, the vzone to use
256 * @return The TimeZone's raw GMT offset.
729e4ab9 257 */
4388f060 258U_CAPI int32_t U_EXPORT2
729e4ab9
A
259vzone_getRawOffset(VZone* zone);
260
261/**
262 * Queries if this time zone uses daylight savings time.
263 * @param zone, the vzone to use
264 * @return true if this time zone uses daylight savings time,
265 * false, otherwise.
729e4ab9 266 */
4388f060 267U_CAPI UBool U_EXPORT2
729e4ab9
A
268vzone_useDaylightTime(VZone* zone);
269
270/**
271 * Queries if the given date is in daylight savings time in
272 * this time zone.
273 * This method is wasteful since it creates a new GregorianCalendar and
274 * deletes it each time it is called. This is a deprecated method
275 * and provided only for Java compatibility.
276 *
277 * @param zone, the vzone to use
278 * @param date the given UDate.
279 * @param status Output param filled in with success/error code.
280 * @return true if the given date is in daylight savings time,
281 * false, otherwise.
729e4ab9 282 */
4388f060 283U_INTERNAL UBool U_EXPORT2
729e4ab9
A
284vzone_inDaylightTime(VZone* zone, UDate date, UErrorCode& status);
285
286/**
287 * Returns true if this zone has the same rule and offset as another zone.
288 * That is, if this zone differs only in ID, if at all.
289 * @param zone, the vzone to use
290 * @param other the <code>TimeZone</code> object to be compared with
291 * @return true if the given zone is the same as this one,
292 * with the possible exception of the ID
729e4ab9 293 */
4388f060 294U_CAPI UBool U_EXPORT2
729e4ab9
A
295vzone_hasSameRules(VZone* zone, const VZone* other);
296
297/**
298 * Gets the first time zone transition after the base time.
299 * @param zone, the vzone to use
300 * @param base The base time.
301 * @param inclusive Whether the base time is inclusive or not.
302 * @param result Receives the first transition after the base time.
303 * @return TRUE if the transition is found.
729e4ab9 304 */
4388f060 305U_CAPI UBool U_EXPORT2
729e4ab9
A
306vzone_getNextTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result);
307
308/**
309 * Gets the most recent time zone transition before the base time.
310 * @param zone, the vzone to use
311 * @param base The base time.
312 * @param inclusive Whether the base time is inclusive or not.
313 * @param result Receives the most recent transition before the base time.
314 * @return TRUE if the transition is found.
729e4ab9 315 */
4388f060 316U_CAPI UBool U_EXPORT2
729e4ab9
A
317vzone_getPreviousTransition(VZone* zone, UDate base, UBool inclusive, ZTrans* result);
318
319/**
320 * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
321 * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
322 * <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
323 * @param zone, the vzone to use
324 * @param status Receives error status code.
325 * @return The number of <code>TimeZoneRule</code>s representing time transitions.
729e4ab9 326 */
4388f060 327U_CAPI int32_t U_EXPORT2
729e4ab9
A
328vzone_countTransitionRules(VZone* zone, UErrorCode& status);
329
330/**
331 * Return the class ID for this class. This is useful only for comparing to
332 * a return value from getDynamicClassID(). For example:
333 * <pre>
334 * . Base* polymorphic_pointer = createPolymorphicObject();
335 * . if (polymorphic_pointer->getDynamicClassID() ==
336 * . erived::getStaticClassID()) ...
337 * </pre>
338 * @param zone, the vzone to use
339 * @return The class ID for all objects of this class.
729e4ab9 340 */
4388f060 341U_CAPI UClassID U_EXPORT2
729e4ab9
A
342vzone_getStaticClassID(VZone* zone);
343
344/**
345 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
346 * method is to implement a simple version of RTTI, since not all C++
347 * compilers support genuine RTTI. Polymorphic operator==() and clone()
348 * methods call this method.
349 *
350 * @param zone, the vzone to use
351 * @return The class ID for this object. All objects of a
352 * given class have the same class ID. Objects of
353 * other classes have different class IDs.
729e4ab9 354 */
4388f060 355U_CAPI UClassID U_EXPORT2
729e4ab9
A
356vzone_getDynamicClassID(VZone* zone);
357
358#endif // __VZONE_H
359
360#endif