michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2009-2011, International Business Machines Corporation and * michael@0: * others. All Rights Reserved. * michael@0: ******************************************************************************* michael@0: */ michael@0: #ifndef __ZRULE_H michael@0: #define __ZRULE_H michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C API: Time zone rule classes michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #ifndef UCNV_H michael@0: michael@0: /** michael@0: * A TimeZoneRule. Use the zrule_* API to manipulate. Create with michael@0: * zrule_open*, and destroy with zrule_close. michael@0: */ michael@0: struct ZRule; michael@0: typedef struct ZRule ZRule; michael@0: michael@0: /** michael@0: * An InitialTimeZoneRule. Use the izrule_* API to manipulate. Create with michael@0: * izrule_open*, and destroy with izrule_close. michael@0: */ michael@0: struct IZRule; michael@0: typedef struct IZRule IZRule; michael@0: michael@0: /** michael@0: * An AnnualTimeZoneRule. Use the azrule_* API to manipulate. Create with michael@0: * azrule_open*, and destroy with azrule_close. michael@0: */ michael@0: struct AZRule; michael@0: typedef struct AZRule AZRule; michael@0: michael@0: #endif michael@0: michael@0: /********************************************************************* michael@0: * ZRule API michael@0: *********************************************************************/ michael@0: michael@0: /** michael@0: * Disposes of the storage used by a ZRule object. This function should michael@0: * be called exactly once for objects returned by zrule_open*. michael@0: * @param set the object to dispose of michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: zrule_close(ZRule* rule); michael@0: michael@0: /** michael@0: * Returns true if rule1 is identical to rule2 michael@0: * and vis versa. michael@0: * @param rule1 to be checked for containment michael@0: * @param rule2 to be checked for containment michael@0: * @return true if the test condition is met michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: zrule_equals(const ZRule* rule1, const ZRule* rule2); michael@0: michael@0: /** michael@0: * Fills in "name" with the name of this time zone. michael@0: * @param rule, the Zrule to use michael@0: * @param name Receives the name of this time zone. michael@0: * @param nameLength, length of the returned name michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: zrule_getName(ZRule* rule, UChar* name, int32_t nameLength); michael@0: michael@0: /** michael@0: * Gets the standard time offset. michael@0: * @param rule, the Zrule to use michael@0: * @return The standard time offset from UTC in milliseconds. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 michael@0: zrule_getRawOffset(ZRule* rule); michael@0: michael@0: /** michael@0: * Gets the amount of daylight saving delta time from the standard time. michael@0: * @param rule, the Zrule to use michael@0: * @return The amount of daylight saving offset used by this rule michael@0: * in milliseconds. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 michael@0: zrule_getDSTSavings(ZRule* rule); michael@0: michael@0: /** michael@0: * Returns if this rule represents the same rule and offsets as another. michael@0: * When two ZRule objects differ only its names, this method michael@0: * returns true. michael@0: * @param rule1 to be checked for containment michael@0: * @param rule2 to be checked for containment michael@0: * @return true if the other TimeZoneRule is the same as this one. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: zrule_isEquivalentTo(ZRule* rule1, ZRule* rule2); michael@0: michael@0: /********************************************************************* michael@0: * IZRule API michael@0: *********************************************************************/ michael@0: michael@0: /** michael@0: * Constructs an IZRule with the name, the GMT offset of its michael@0: * standard time and the amount of daylight saving offset adjustment. michael@0: * @param name The time zone name. michael@0: * @param nameLength The length of the time zone name. michael@0: * @param rawOffset The UTC offset of its standard time in milliseconds. michael@0: * @param dstSavings The amount of daylight saving offset adjustment in milliseconds. michael@0: * If this ia a rule for standard time, the value of this argument is 0. michael@0: */ michael@0: U_CAPI IZRule* U_EXPORT2 michael@0: izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings); michael@0: michael@0: /** michael@0: * Disposes of the storage used by a IZRule object. This function should michael@0: * be called exactly once for objects returned by izrule_open*. michael@0: * @param set the object to dispose of michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: izrule_close(IZRule* rule); michael@0: michael@0: /** michael@0: * Returns a copy of this object. michael@0: * @param rule the original IZRule michael@0: * @return the newly allocated copy of the IZRule michael@0: */ michael@0: U_CAPI IZRule* U_EXPORT2 michael@0: izrule_clone(IZRule *rule); michael@0: michael@0: /** michael@0: * Returns true if rule1 is identical to rule2 michael@0: * and vis versa. michael@0: * @param rule1 to be checked for containment michael@0: * @param rule2 to be checked for containment michael@0: * @return true if the test condition is met michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: izrule_equals(const IZRule* rule1, const IZRule* rule2); michael@0: michael@0: /** michael@0: * Fills in "name" with the name of this time zone. michael@0: * @param rule, the IZrule to use michael@0: * @param name Receives the name of this time zone. michael@0: * @param nameLength, length of the returned name michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength); michael@0: michael@0: /** michael@0: * Gets the standard time offset. michael@0: * @param rule, the IZrule to use michael@0: * @return The standard time offset from UTC in milliseconds. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 michael@0: izrule_getRawOffset(IZRule* rule); michael@0: michael@0: /** michael@0: * Gets the amount of daylight saving delta time from the standard time. michael@0: * @param rule, the IZrule to use michael@0: * @return The amount of daylight saving offset used by this rule michael@0: * in milliseconds. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 michael@0: izrule_getDSTSavings(IZRule* rule); michael@0: michael@0: /** michael@0: * Returns if this rule represents the same rule and offsets as another. michael@0: * When two IZRule objects differ only its names, this method michael@0: * returns true. michael@0: * @param rule1 to be checked for containment michael@0: * @param rule2 to be checked for containment michael@0: * @return true if the other TimeZoneRule is the same as this one. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: izrule_isEquivalentTo(IZRule* rule1, IZRule* rule2); michael@0: michael@0: /** michael@0: * Gets the very first time when this rule takes effect. michael@0: * @param rule The IZrule to use michael@0: * @param prevRawOffset The standard time offset from UTC before this rule michael@0: * takes effect in milliseconds. michael@0: * @param prevDSTSavings The amount of daylight saving offset from the michael@0: * standard time. michael@0: * @param result Receives the very first time when this rule takes effect. michael@0: * @return true if the start time is available. When false is returned, output parameter michael@0: * "result" is unchanged. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, michael@0: UDate& result); michael@0: michael@0: /** michael@0: * Gets the final time when this rule takes effect. michael@0: * @param rule The IZrule to use michael@0: * @param prevRawOffset The standard time offset from UTC before this rule michael@0: * takes effect in milliseconds. michael@0: * @param prevDSTSavings The amount of daylight saving offset from the michael@0: * standard time. michael@0: * @param result Receives the final time when this rule takes effect. michael@0: * @return true if the start time is available. When false is returned, output parameter michael@0: * "result" is unchanged. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, michael@0: UDate& result); michael@0: michael@0: /** michael@0: * Gets the first time when this rule takes effect after the specified time. michael@0: * @param rule The IZrule to use michael@0: * @param base The first start time after this base time will be returned. michael@0: * @param prevRawOffset The standard time offset from UTC before this rule michael@0: * takes effect in milliseconds. michael@0: * @param prevDSTSavings The amount of daylight saving offset from the michael@0: * standard time. michael@0: * @param inclusive Whether the base time is inclusive or not. michael@0: * @param result Receives The first time when this rule takes effect after michael@0: * the specified base time. michael@0: * @return true if the start time is available. When false is returned, output parameter michael@0: * "result" is unchanged. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, michael@0: int32_t prevDSTSavings, UBool inclusive, UDate& result); michael@0: michael@0: /** michael@0: * Gets the most recent time when this rule takes effect before the specified time. michael@0: * @param rule The IZrule to use michael@0: * @param base The most recent time before this base time will be returned. michael@0: * @param prevRawOffset The standard time offset from UTC before this rule michael@0: * takes effect in milliseconds. michael@0: * @param prevDSTSavings The amount of daylight saving offset from the michael@0: * standard time. michael@0: * @param inclusive Whether the base time is inclusive or not. michael@0: * @param result Receives The most recent time when this rule takes effect before michael@0: * the specified base time. michael@0: * @return true if the start time is available. When false is returned, output parameter michael@0: * "result" is unchanged. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, michael@0: int32_t prevDSTSavings, UBool inclusive, UDate& result); michael@0: michael@0: michael@0: /** michael@0: * Return the class ID for this class. This is useful only for comparing to michael@0: * a return value from getDynamicClassID(). For example: michael@0: *
michael@0:  * .   Base* polymorphic_pointer = createPolymorphicObject();
michael@0:  * .   if (polymorphic_pointer->getDynamicClassID() ==
michael@0:  * .       erived::getStaticClassID()) ...
michael@0:  * 
michael@0: * @param rule The IZrule to use michael@0: * @return The class ID for all objects of this class. michael@0: */ michael@0: U_CAPI UClassID U_EXPORT2 michael@0: izrule_getStaticClassID(IZRule* rule); michael@0: michael@0: /** michael@0: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This michael@0: * method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() michael@0: * methods call this method. michael@0: * michael@0: * @param rule The IZrule to use michael@0: * @return The class ID for this object. All objects of a michael@0: * given class have the same class ID. Objects of michael@0: * other classes have different class IDs. michael@0: */ michael@0: U_CAPI UClassID U_EXPORT2 michael@0: izrule_getDynamicClassID(IZRule* rule); michael@0: michael@0: #endif michael@0: michael@0: #endif