1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/zrule.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,279 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2009-2011, International Business Machines Corporation and * 1.7 +* others. All Rights Reserved. * 1.8 +******************************************************************************* 1.9 +*/ 1.10 +#ifndef __ZRULE_H 1.11 +#define __ZRULE_H 1.12 + 1.13 +/** 1.14 + * \file 1.15 + * \brief C API: Time zone rule classes 1.16 + */ 1.17 + 1.18 +#include "unicode/utypes.h" 1.19 + 1.20 +#if !UCONFIG_NO_FORMATTING 1.21 + 1.22 +#ifndef UCNV_H 1.23 + 1.24 +/** 1.25 + * A TimeZoneRule. Use the zrule_* API to manipulate. Create with 1.26 + * zrule_open*, and destroy with zrule_close. 1.27 + */ 1.28 +struct ZRule; 1.29 +typedef struct ZRule ZRule; 1.30 + 1.31 +/** 1.32 + * An InitialTimeZoneRule. Use the izrule_* API to manipulate. Create with 1.33 + * izrule_open*, and destroy with izrule_close. 1.34 + */ 1.35 +struct IZRule; 1.36 +typedef struct IZRule IZRule; 1.37 + 1.38 +/** 1.39 + * An AnnualTimeZoneRule. Use the azrule_* API to manipulate. Create with 1.40 + * azrule_open*, and destroy with azrule_close. 1.41 + */ 1.42 +struct AZRule; 1.43 +typedef struct AZRule AZRule; 1.44 + 1.45 +#endif 1.46 + 1.47 +/********************************************************************* 1.48 + * ZRule API 1.49 + *********************************************************************/ 1.50 + 1.51 +/** 1.52 + * Disposes of the storage used by a ZRule object. This function should 1.53 + * be called exactly once for objects returned by zrule_open*. 1.54 + * @param set the object to dispose of 1.55 + */ 1.56 +U_CAPI void U_EXPORT2 1.57 +zrule_close(ZRule* rule); 1.58 + 1.59 +/** 1.60 + * Returns true if rule1 is identical to rule2 1.61 + * and vis versa. 1.62 + * @param rule1 to be checked for containment 1.63 + * @param rule2 to be checked for containment 1.64 + * @return true if the test condition is met 1.65 + */ 1.66 +U_CAPI UBool U_EXPORT2 1.67 +zrule_equals(const ZRule* rule1, const ZRule* rule2); 1.68 + 1.69 +/** 1.70 + * Fills in "name" with the name of this time zone. 1.71 + * @param rule, the Zrule to use 1.72 + * @param name Receives the name of this time zone. 1.73 + * @param nameLength, length of the returned name 1.74 + */ 1.75 +U_CAPI void U_EXPORT2 1.76 +zrule_getName(ZRule* rule, UChar* name, int32_t nameLength); 1.77 + 1.78 +/** 1.79 + * Gets the standard time offset. 1.80 + * @param rule, the Zrule to use 1.81 + * @return The standard time offset from UTC in milliseconds. 1.82 + */ 1.83 +U_CAPI int32_t U_EXPORT2 1.84 +zrule_getRawOffset(ZRule* rule); 1.85 + 1.86 +/** 1.87 + * Gets the amount of daylight saving delta time from the standard time. 1.88 + * @param rule, the Zrule to use 1.89 + * @return The amount of daylight saving offset used by this rule 1.90 + * in milliseconds. 1.91 + */ 1.92 +U_CAPI int32_t U_EXPORT2 1.93 +zrule_getDSTSavings(ZRule* rule); 1.94 + 1.95 +/** 1.96 + * Returns if this rule represents the same rule and offsets as another. 1.97 + * When two ZRule objects differ only its names, this method 1.98 + * returns true. 1.99 + * @param rule1 to be checked for containment 1.100 + * @param rule2 to be checked for containment 1.101 + * @return true if the other <code>TimeZoneRule</code> is the same as this one. 1.102 + */ 1.103 +U_CAPI UBool U_EXPORT2 1.104 +zrule_isEquivalentTo(ZRule* rule1, ZRule* rule2); 1.105 + 1.106 +/********************************************************************* 1.107 + * IZRule API 1.108 + *********************************************************************/ 1.109 + 1.110 +/** 1.111 + * Constructs an IZRule with the name, the GMT offset of its 1.112 + * standard time and the amount of daylight saving offset adjustment. 1.113 + * @param name The time zone name. 1.114 + * @param nameLength The length of the time zone name. 1.115 + * @param rawOffset The UTC offset of its standard time in milliseconds. 1.116 + * @param dstSavings The amount of daylight saving offset adjustment in milliseconds. 1.117 + * If this ia a rule for standard time, the value of this argument is 0. 1.118 + */ 1.119 +U_CAPI IZRule* U_EXPORT2 1.120 +izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings); 1.121 + 1.122 +/** 1.123 + * Disposes of the storage used by a IZRule object. This function should 1.124 + * be called exactly once for objects returned by izrule_open*. 1.125 + * @param set the object to dispose of 1.126 + */ 1.127 +U_CAPI void U_EXPORT2 1.128 +izrule_close(IZRule* rule); 1.129 + 1.130 +/** 1.131 + * Returns a copy of this object. 1.132 + * @param rule the original IZRule 1.133 + * @return the newly allocated copy of the IZRule 1.134 + */ 1.135 +U_CAPI IZRule* U_EXPORT2 1.136 +izrule_clone(IZRule *rule); 1.137 + 1.138 +/** 1.139 + * Returns true if rule1 is identical to rule2 1.140 + * and vis versa. 1.141 + * @param rule1 to be checked for containment 1.142 + * @param rule2 to be checked for containment 1.143 + * @return true if the test condition is met 1.144 + */ 1.145 +U_CAPI UBool U_EXPORT2 1.146 +izrule_equals(const IZRule* rule1, const IZRule* rule2); 1.147 + 1.148 +/** 1.149 + * Fills in "name" with the name of this time zone. 1.150 + * @param rule, the IZrule to use 1.151 + * @param name Receives the name of this time zone. 1.152 + * @param nameLength, length of the returned name 1.153 + */ 1.154 +U_CAPI void U_EXPORT2 1.155 +izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength); 1.156 + 1.157 +/** 1.158 + * Gets the standard time offset. 1.159 + * @param rule, the IZrule to use 1.160 + * @return The standard time offset from UTC in milliseconds. 1.161 + */ 1.162 +U_CAPI int32_t U_EXPORT2 1.163 +izrule_getRawOffset(IZRule* rule); 1.164 + 1.165 +/** 1.166 + * Gets the amount of daylight saving delta time from the standard time. 1.167 + * @param rule, the IZrule to use 1.168 + * @return The amount of daylight saving offset used by this rule 1.169 + * in milliseconds. 1.170 + */ 1.171 +U_CAPI int32_t U_EXPORT2 1.172 +izrule_getDSTSavings(IZRule* rule); 1.173 + 1.174 +/** 1.175 + * Returns if this rule represents the same rule and offsets as another. 1.176 + * When two IZRule objects differ only its names, this method 1.177 + * returns true. 1.178 + * @param rule1 to be checked for containment 1.179 + * @param rule2 to be checked for containment 1.180 + * @return true if the other <code>TimeZoneRule</code> is the same as this one. 1.181 + */ 1.182 +U_CAPI UBool U_EXPORT2 1.183 +izrule_isEquivalentTo(IZRule* rule1, IZRule* rule2); 1.184 + 1.185 +/** 1.186 + * Gets the very first time when this rule takes effect. 1.187 + * @param rule The IZrule to use 1.188 + * @param prevRawOffset The standard time offset from UTC before this rule 1.189 + * takes effect in milliseconds. 1.190 + * @param prevDSTSavings The amount of daylight saving offset from the 1.191 + * standard time. 1.192 + * @param result Receives the very first time when this rule takes effect. 1.193 + * @return true if the start time is available. When false is returned, output parameter 1.194 + * "result" is unchanged. 1.195 + */ 1.196 +U_CAPI UBool U_EXPORT2 1.197 +izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, 1.198 + UDate& result); 1.199 + 1.200 +/** 1.201 + * Gets the final time when this rule takes effect. 1.202 + * @param rule The IZrule to use 1.203 + * @param prevRawOffset The standard time offset from UTC before this rule 1.204 + * takes effect in milliseconds. 1.205 + * @param prevDSTSavings The amount of daylight saving offset from the 1.206 + * standard time. 1.207 + * @param result Receives the final time when this rule takes effect. 1.208 + * @return true if the start time is available. When false is returned, output parameter 1.209 + * "result" is unchanged. 1.210 + */ 1.211 +U_CAPI UBool U_EXPORT2 1.212 +izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, 1.213 + UDate& result); 1.214 + 1.215 +/** 1.216 + * Gets the first time when this rule takes effect after the specified time. 1.217 + * @param rule The IZrule to use 1.218 + * @param base The first start time after this base time will be returned. 1.219 + * @param prevRawOffset The standard time offset from UTC before this rule 1.220 + * takes effect in milliseconds. 1.221 + * @param prevDSTSavings The amount of daylight saving offset from the 1.222 + * standard time. 1.223 + * @param inclusive Whether the base time is inclusive or not. 1.224 + * @param result Receives The first time when this rule takes effect after 1.225 + * the specified base time. 1.226 + * @return true if the start time is available. When false is returned, output parameter 1.227 + * "result" is unchanged. 1.228 + */ 1.229 +U_CAPI UBool U_EXPORT2 1.230 +izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, 1.231 + int32_t prevDSTSavings, UBool inclusive, UDate& result); 1.232 + 1.233 +/** 1.234 + * Gets the most recent time when this rule takes effect before the specified time. 1.235 + * @param rule The IZrule to use 1.236 + * @param base The most recent time before this base time will be returned. 1.237 + * @param prevRawOffset The standard time offset from UTC before this rule 1.238 + * takes effect in milliseconds. 1.239 + * @param prevDSTSavings The amount of daylight saving offset from the 1.240 + * standard time. 1.241 + * @param inclusive Whether the base time is inclusive or not. 1.242 + * @param result Receives The most recent time when this rule takes effect before 1.243 + * the specified base time. 1.244 + * @return true if the start time is available. When false is returned, output parameter 1.245 + * "result" is unchanged. 1.246 + */ 1.247 +U_CAPI UBool U_EXPORT2 1.248 +izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, 1.249 + int32_t prevDSTSavings, UBool inclusive, UDate& result); 1.250 + 1.251 + 1.252 +/** 1.253 + * Return the class ID for this class. This is useful only for comparing to 1.254 + * a return value from getDynamicClassID(). For example: 1.255 + * <pre> 1.256 + * . Base* polymorphic_pointer = createPolymorphicObject(); 1.257 + * . if (polymorphic_pointer->getDynamicClassID() == 1.258 + * . erived::getStaticClassID()) ... 1.259 + * </pre> 1.260 + * @param rule The IZrule to use 1.261 + * @return The class ID for all objects of this class. 1.262 + */ 1.263 +U_CAPI UClassID U_EXPORT2 1.264 +izrule_getStaticClassID(IZRule* rule); 1.265 + 1.266 +/** 1.267 + * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 1.268 + * method is to implement a simple version of RTTI, since not all C++ 1.269 + * compilers support genuine RTTI. Polymorphic operator==() and clone() 1.270 + * methods call this method. 1.271 + * 1.272 + * @param rule The IZrule to use 1.273 + * @return The class ID for this object. All objects of a 1.274 + * given class have the same class ID. Objects of 1.275 + * other classes have different class IDs. 1.276 + */ 1.277 +U_CAPI UClassID U_EXPORT2 1.278 +izrule_getDynamicClassID(IZRule* rule); 1.279 + 1.280 +#endif 1.281 + 1.282 +#endif