intl/icu/source/i18n/zrule.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 * Copyright (C) 2009-2011, International Business Machines Corporation and *
michael@0 4 * others. All Rights Reserved. *
michael@0 5 *******************************************************************************
michael@0 6 */
michael@0 7 #ifndef __ZRULE_H
michael@0 8 #define __ZRULE_H
michael@0 9
michael@0 10 /**
michael@0 11 * \file
michael@0 12 * \brief C API: Time zone rule classes
michael@0 13 */
michael@0 14
michael@0 15 #include "unicode/utypes.h"
michael@0 16
michael@0 17 #if !UCONFIG_NO_FORMATTING
michael@0 18
michael@0 19 #ifndef UCNV_H
michael@0 20
michael@0 21 /**
michael@0 22 * A TimeZoneRule. Use the zrule_* API to manipulate. Create with
michael@0 23 * zrule_open*, and destroy with zrule_close.
michael@0 24 */
michael@0 25 struct ZRule;
michael@0 26 typedef struct ZRule ZRule;
michael@0 27
michael@0 28 /**
michael@0 29 * An InitialTimeZoneRule. Use the izrule_* API to manipulate. Create with
michael@0 30 * izrule_open*, and destroy with izrule_close.
michael@0 31 */
michael@0 32 struct IZRule;
michael@0 33 typedef struct IZRule IZRule;
michael@0 34
michael@0 35 /**
michael@0 36 * An AnnualTimeZoneRule. Use the azrule_* API to manipulate. Create with
michael@0 37 * azrule_open*, and destroy with azrule_close.
michael@0 38 */
michael@0 39 struct AZRule;
michael@0 40 typedef struct AZRule AZRule;
michael@0 41
michael@0 42 #endif
michael@0 43
michael@0 44 /*********************************************************************
michael@0 45 * ZRule API
michael@0 46 *********************************************************************/
michael@0 47
michael@0 48 /**
michael@0 49 * Disposes of the storage used by a ZRule object. This function should
michael@0 50 * be called exactly once for objects returned by zrule_open*.
michael@0 51 * @param set the object to dispose of
michael@0 52 */
michael@0 53 U_CAPI void U_EXPORT2
michael@0 54 zrule_close(ZRule* rule);
michael@0 55
michael@0 56 /**
michael@0 57 * Returns true if rule1 is identical to rule2
michael@0 58 * and vis versa.
michael@0 59 * @param rule1 to be checked for containment
michael@0 60 * @param rule2 to be checked for containment
michael@0 61 * @return true if the test condition is met
michael@0 62 */
michael@0 63 U_CAPI UBool U_EXPORT2
michael@0 64 zrule_equals(const ZRule* rule1, const ZRule* rule2);
michael@0 65
michael@0 66 /**
michael@0 67 * Fills in "name" with the name of this time zone.
michael@0 68 * @param rule, the Zrule to use
michael@0 69 * @param name Receives the name of this time zone.
michael@0 70 * @param nameLength, length of the returned name
michael@0 71 */
michael@0 72 U_CAPI void U_EXPORT2
michael@0 73 zrule_getName(ZRule* rule, UChar* name, int32_t nameLength);
michael@0 74
michael@0 75 /**
michael@0 76 * Gets the standard time offset.
michael@0 77 * @param rule, the Zrule to use
michael@0 78 * @return The standard time offset from UTC in milliseconds.
michael@0 79 */
michael@0 80 U_CAPI int32_t U_EXPORT2
michael@0 81 zrule_getRawOffset(ZRule* rule);
michael@0 82
michael@0 83 /**
michael@0 84 * Gets the amount of daylight saving delta time from the standard time.
michael@0 85 * @param rule, the Zrule to use
michael@0 86 * @return The amount of daylight saving offset used by this rule
michael@0 87 * in milliseconds.
michael@0 88 */
michael@0 89 U_CAPI int32_t U_EXPORT2
michael@0 90 zrule_getDSTSavings(ZRule* rule);
michael@0 91
michael@0 92 /**
michael@0 93 * Returns if this rule represents the same rule and offsets as another.
michael@0 94 * When two ZRule objects differ only its names, this method
michael@0 95 * returns true.
michael@0 96 * @param rule1 to be checked for containment
michael@0 97 * @param rule2 to be checked for containment
michael@0 98 * @return true if the other <code>TimeZoneRule</code> is the same as this one.
michael@0 99 */
michael@0 100 U_CAPI UBool U_EXPORT2
michael@0 101 zrule_isEquivalentTo(ZRule* rule1, ZRule* rule2);
michael@0 102
michael@0 103 /*********************************************************************
michael@0 104 * IZRule API
michael@0 105 *********************************************************************/
michael@0 106
michael@0 107 /**
michael@0 108 * Constructs an IZRule with the name, the GMT offset of its
michael@0 109 * standard time and the amount of daylight saving offset adjustment.
michael@0 110 * @param name The time zone name.
michael@0 111 * @param nameLength The length of the time zone name.
michael@0 112 * @param rawOffset The UTC offset of its standard time in milliseconds.
michael@0 113 * @param dstSavings The amount of daylight saving offset adjustment in milliseconds.
michael@0 114 * If this ia a rule for standard time, the value of this argument is 0.
michael@0 115 */
michael@0 116 U_CAPI IZRule* U_EXPORT2
michael@0 117 izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings);
michael@0 118
michael@0 119 /**
michael@0 120 * Disposes of the storage used by a IZRule object. This function should
michael@0 121 * be called exactly once for objects returned by izrule_open*.
michael@0 122 * @param set the object to dispose of
michael@0 123 */
michael@0 124 U_CAPI void U_EXPORT2
michael@0 125 izrule_close(IZRule* rule);
michael@0 126
michael@0 127 /**
michael@0 128 * Returns a copy of this object.
michael@0 129 * @param rule the original IZRule
michael@0 130 * @return the newly allocated copy of the IZRule
michael@0 131 */
michael@0 132 U_CAPI IZRule* U_EXPORT2
michael@0 133 izrule_clone(IZRule *rule);
michael@0 134
michael@0 135 /**
michael@0 136 * Returns true if rule1 is identical to rule2
michael@0 137 * and vis versa.
michael@0 138 * @param rule1 to be checked for containment
michael@0 139 * @param rule2 to be checked for containment
michael@0 140 * @return true if the test condition is met
michael@0 141 */
michael@0 142 U_CAPI UBool U_EXPORT2
michael@0 143 izrule_equals(const IZRule* rule1, const IZRule* rule2);
michael@0 144
michael@0 145 /**
michael@0 146 * Fills in "name" with the name of this time zone.
michael@0 147 * @param rule, the IZrule to use
michael@0 148 * @param name Receives the name of this time zone.
michael@0 149 * @param nameLength, length of the returned name
michael@0 150 */
michael@0 151 U_CAPI void U_EXPORT2
michael@0 152 izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength);
michael@0 153
michael@0 154 /**
michael@0 155 * Gets the standard time offset.
michael@0 156 * @param rule, the IZrule to use
michael@0 157 * @return The standard time offset from UTC in milliseconds.
michael@0 158 */
michael@0 159 U_CAPI int32_t U_EXPORT2
michael@0 160 izrule_getRawOffset(IZRule* rule);
michael@0 161
michael@0 162 /**
michael@0 163 * Gets the amount of daylight saving delta time from the standard time.
michael@0 164 * @param rule, the IZrule to use
michael@0 165 * @return The amount of daylight saving offset used by this rule
michael@0 166 * in milliseconds.
michael@0 167 */
michael@0 168 U_CAPI int32_t U_EXPORT2
michael@0 169 izrule_getDSTSavings(IZRule* rule);
michael@0 170
michael@0 171 /**
michael@0 172 * Returns if this rule represents the same rule and offsets as another.
michael@0 173 * When two IZRule objects differ only its names, this method
michael@0 174 * returns true.
michael@0 175 * @param rule1 to be checked for containment
michael@0 176 * @param rule2 to be checked for containment
michael@0 177 * @return true if the other <code>TimeZoneRule</code> is the same as this one.
michael@0 178 */
michael@0 179 U_CAPI UBool U_EXPORT2
michael@0 180 izrule_isEquivalentTo(IZRule* rule1, IZRule* rule2);
michael@0 181
michael@0 182 /**
michael@0 183 * Gets the very first time when this rule takes effect.
michael@0 184 * @param rule The IZrule to use
michael@0 185 * @param prevRawOffset The standard time offset from UTC before this rule
michael@0 186 * takes effect in milliseconds.
michael@0 187 * @param prevDSTSavings The amount of daylight saving offset from the
michael@0 188 * standard time.
michael@0 189 * @param result Receives the very first time when this rule takes effect.
michael@0 190 * @return true if the start time is available. When false is returned, output parameter
michael@0 191 * "result" is unchanged.
michael@0 192 */
michael@0 193 U_CAPI UBool U_EXPORT2
michael@0 194 izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0 195 UDate& result);
michael@0 196
michael@0 197 /**
michael@0 198 * Gets the final time when this rule takes effect.
michael@0 199 * @param rule The IZrule to use
michael@0 200 * @param prevRawOffset The standard time offset from UTC before this rule
michael@0 201 * takes effect in milliseconds.
michael@0 202 * @param prevDSTSavings The amount of daylight saving offset from the
michael@0 203 * standard time.
michael@0 204 * @param result Receives the final time when this rule takes effect.
michael@0 205 * @return true if the start time is available. When false is returned, output parameter
michael@0 206 * "result" is unchanged.
michael@0 207 */
michael@0 208 U_CAPI UBool U_EXPORT2
michael@0 209 izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings,
michael@0 210 UDate& result);
michael@0 211
michael@0 212 /**
michael@0 213 * Gets the first time when this rule takes effect after the specified time.
michael@0 214 * @param rule The IZrule to use
michael@0 215 * @param base The first start time after this base time will be returned.
michael@0 216 * @param prevRawOffset The standard time offset from UTC before this rule
michael@0 217 * takes effect in milliseconds.
michael@0 218 * @param prevDSTSavings The amount of daylight saving offset from the
michael@0 219 * standard time.
michael@0 220 * @param inclusive Whether the base time is inclusive or not.
michael@0 221 * @param result Receives The first time when this rule takes effect after
michael@0 222 * the specified base time.
michael@0 223 * @return true if the start time is available. When false is returned, output parameter
michael@0 224 * "result" is unchanged.
michael@0 225 */
michael@0 226 U_CAPI UBool U_EXPORT2
michael@0 227 izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset,
michael@0 228 int32_t prevDSTSavings, UBool inclusive, UDate& result);
michael@0 229
michael@0 230 /**
michael@0 231 * Gets the most recent time when this rule takes effect before the specified time.
michael@0 232 * @param rule The IZrule to use
michael@0 233 * @param base The most recent time before this base time will be returned.
michael@0 234 * @param prevRawOffset The standard time offset from UTC before this rule
michael@0 235 * takes effect in milliseconds.
michael@0 236 * @param prevDSTSavings The amount of daylight saving offset from the
michael@0 237 * standard time.
michael@0 238 * @param inclusive Whether the base time is inclusive or not.
michael@0 239 * @param result Receives The most recent time when this rule takes effect before
michael@0 240 * the specified base time.
michael@0 241 * @return true if the start time is available. When false is returned, output parameter
michael@0 242 * "result" is unchanged.
michael@0 243 */
michael@0 244 U_CAPI UBool U_EXPORT2
michael@0 245 izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset,
michael@0 246 int32_t prevDSTSavings, UBool inclusive, UDate& result);
michael@0 247
michael@0 248
michael@0 249 /**
michael@0 250 * Return the class ID for this class. This is useful only for comparing to
michael@0 251 * a return value from getDynamicClassID(). For example:
michael@0 252 * <pre>
michael@0 253 * . Base* polymorphic_pointer = createPolymorphicObject();
michael@0 254 * . if (polymorphic_pointer->getDynamicClassID() ==
michael@0 255 * . erived::getStaticClassID()) ...
michael@0 256 * </pre>
michael@0 257 * @param rule The IZrule to use
michael@0 258 * @return The class ID for all objects of this class.
michael@0 259 */
michael@0 260 U_CAPI UClassID U_EXPORT2
michael@0 261 izrule_getStaticClassID(IZRule* rule);
michael@0 262
michael@0 263 /**
michael@0 264 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
michael@0 265 * method is to implement a simple version of RTTI, since not all C++
michael@0 266 * compilers support genuine RTTI. Polymorphic operator==() and clone()
michael@0 267 * methods call this method.
michael@0 268 *
michael@0 269 * @param rule The IZrule to use
michael@0 270 * @return The class ID for this object. All objects of a
michael@0 271 * given class have the same class ID. Objects of
michael@0 272 * other classes have different class IDs.
michael@0 273 */
michael@0 274 U_CAPI UClassID U_EXPORT2
michael@0 275 izrule_getDynamicClassID(IZRule* rule);
michael@0 276
michael@0 277 #endif
michael@0 278
michael@0 279 #endif

mercurial