1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2007-2008, International Business Machines Corporation and * 6*0e209d39SAndroid Build Coastguard Worker * others. All Rights Reserved. * 7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 8*0e209d39SAndroid Build Coastguard Worker */ 9*0e209d39SAndroid Build Coastguard Worker #ifndef TZRULE_H 10*0e209d39SAndroid Build Coastguard Worker #define TZRULE_H 11*0e209d39SAndroid Build Coastguard Worker 12*0e209d39SAndroid Build Coastguard Worker /** 13*0e209d39SAndroid Build Coastguard Worker * \file 14*0e209d39SAndroid Build Coastguard Worker * \brief C++ API: Time zone rule classes 15*0e209d39SAndroid Build Coastguard Worker */ 16*0e209d39SAndroid Build Coastguard Worker 17*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 18*0e209d39SAndroid Build Coastguard Worker 19*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 22*0e209d39SAndroid Build Coastguard Worker 23*0e209d39SAndroid Build Coastguard Worker #include "unicode/uobject.h" 24*0e209d39SAndroid Build Coastguard Worker #include "unicode/unistr.h" 25*0e209d39SAndroid Build Coastguard Worker #include "unicode/dtrule.h" 26*0e209d39SAndroid Build Coastguard Worker 27*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 28*0e209d39SAndroid Build Coastguard Worker 29*0e209d39SAndroid Build Coastguard Worker /** 30*0e209d39SAndroid Build Coastguard Worker * <code>TimeZoneRule</code> is a class representing a rule for time zone. 31*0e209d39SAndroid Build Coastguard Worker * <code>TimeZoneRule</code> has a set of time zone attributes, such as zone name, 32*0e209d39SAndroid Build Coastguard Worker * raw offset (UTC offset for standard time) and daylight saving time offset. 33*0e209d39SAndroid Build Coastguard Worker * 34*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 35*0e209d39SAndroid Build Coastguard Worker */ 36*0e209d39SAndroid Build Coastguard Worker class U_I18N_API TimeZoneRule : public UObject { 37*0e209d39SAndroid Build Coastguard Worker public: 38*0e209d39SAndroid Build Coastguard Worker /** 39*0e209d39SAndroid Build Coastguard Worker * Destructor. 40*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 41*0e209d39SAndroid Build Coastguard Worker */ 42*0e209d39SAndroid Build Coastguard Worker virtual ~TimeZoneRule(); 43*0e209d39SAndroid Build Coastguard Worker 44*0e209d39SAndroid Build Coastguard Worker /** 45*0e209d39SAndroid Build Coastguard Worker * Clone this TimeZoneRule object polymorphically. The caller owns the result and 46*0e209d39SAndroid Build Coastguard Worker * should delete it when done. 47*0e209d39SAndroid Build Coastguard Worker * @return A copy of the object. 48*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 49*0e209d39SAndroid Build Coastguard Worker */ 50*0e209d39SAndroid Build Coastguard Worker virtual TimeZoneRule* clone() const = 0; 51*0e209d39SAndroid Build Coastguard Worker 52*0e209d39SAndroid Build Coastguard Worker /** 53*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 54*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 55*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 56*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 57*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 58*0e209d39SAndroid Build Coastguard Worker */ 59*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const TimeZoneRule& that) const; 60*0e209d39SAndroid Build Coastguard Worker 61*0e209d39SAndroid Build Coastguard Worker /** 62*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 63*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 64*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 65*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 66*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 67*0e209d39SAndroid Build Coastguard Worker */ 68*0e209d39SAndroid Build Coastguard Worker virtual bool operator!=(const TimeZoneRule& that) const; 69*0e209d39SAndroid Build Coastguard Worker 70*0e209d39SAndroid Build Coastguard Worker /** 71*0e209d39SAndroid Build Coastguard Worker * Fills in "name" with the name of this time zone. 72*0e209d39SAndroid Build Coastguard Worker * @param name Receives the name of this time zone. 73*0e209d39SAndroid Build Coastguard Worker * @return A reference to "name" 74*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 75*0e209d39SAndroid Build Coastguard Worker */ 76*0e209d39SAndroid Build Coastguard Worker UnicodeString& getName(UnicodeString& name) const; 77*0e209d39SAndroid Build Coastguard Worker 78*0e209d39SAndroid Build Coastguard Worker /** 79*0e209d39SAndroid Build Coastguard Worker * Gets the standard time offset. 80*0e209d39SAndroid Build Coastguard Worker * @return The standard time offset from UTC in milliseconds. 81*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 82*0e209d39SAndroid Build Coastguard Worker */ 83*0e209d39SAndroid Build Coastguard Worker int32_t getRawOffset() const; 84*0e209d39SAndroid Build Coastguard Worker 85*0e209d39SAndroid Build Coastguard Worker /** 86*0e209d39SAndroid Build Coastguard Worker * Gets the amount of daylight saving delta time from the standard time. 87*0e209d39SAndroid Build Coastguard Worker * @return The amount of daylight saving offset used by this rule 88*0e209d39SAndroid Build Coastguard Worker * in milliseconds. 89*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 90*0e209d39SAndroid Build Coastguard Worker */ 91*0e209d39SAndroid Build Coastguard Worker int32_t getDSTSavings() const; 92*0e209d39SAndroid Build Coastguard Worker 93*0e209d39SAndroid Build Coastguard Worker /** 94*0e209d39SAndroid Build Coastguard Worker * Returns if this rule represents the same rule and offsets as another. 95*0e209d39SAndroid Build Coastguard Worker * When two <code>TimeZoneRule</code> objects differ only its names, this method 96*0e209d39SAndroid Build Coastguard Worker * returns true. 97*0e209d39SAndroid Build Coastguard Worker * @param other The <code>TimeZoneRule</code> object to be compared with. 98*0e209d39SAndroid Build Coastguard Worker * @return true if the other <code>TimeZoneRule</code> is the same as this one. 99*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 100*0e209d39SAndroid Build Coastguard Worker */ 101*0e209d39SAndroid Build Coastguard Worker virtual UBool isEquivalentTo(const TimeZoneRule& other) const; 102*0e209d39SAndroid Build Coastguard Worker 103*0e209d39SAndroid Build Coastguard Worker /** 104*0e209d39SAndroid Build Coastguard Worker * Gets the very first time when this rule takes effect. 105*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 106*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 107*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 108*0e209d39SAndroid Build Coastguard Worker * standard time. 109*0e209d39SAndroid Build Coastguard Worker * @param result Receives the very first time when this rule takes effect. 110*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 111*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 112*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 113*0e209d39SAndroid Build Coastguard Worker */ 114*0e209d39SAndroid Build Coastguard Worker virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0; 115*0e209d39SAndroid Build Coastguard Worker 116*0e209d39SAndroid Build Coastguard Worker /** 117*0e209d39SAndroid Build Coastguard Worker * Gets the final time when this rule takes effect. 118*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 119*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 120*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 121*0e209d39SAndroid Build Coastguard Worker * standard time. 122*0e209d39SAndroid Build Coastguard Worker * @param result Receives the final time when this rule takes effect. 123*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 124*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 125*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 126*0e209d39SAndroid Build Coastguard Worker */ 127*0e209d39SAndroid Build Coastguard Worker virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0; 128*0e209d39SAndroid Build Coastguard Worker 129*0e209d39SAndroid Build Coastguard Worker /** 130*0e209d39SAndroid Build Coastguard Worker * Gets the first time when this rule takes effect after the specified time. 131*0e209d39SAndroid Build Coastguard Worker * @param base The first start time after this base time will be returned. 132*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 133*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 134*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 135*0e209d39SAndroid Build Coastguard Worker * standard time. 136*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 137*0e209d39SAndroid Build Coastguard Worker * @param result Receives The first time when this rule takes effect after 138*0e209d39SAndroid Build Coastguard Worker * the specified base time. 139*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 140*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 141*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 142*0e209d39SAndroid Build Coastguard Worker */ 143*0e209d39SAndroid Build Coastguard Worker virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 144*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const = 0; 145*0e209d39SAndroid Build Coastguard Worker 146*0e209d39SAndroid Build Coastguard Worker /** 147*0e209d39SAndroid Build Coastguard Worker * Gets the most recent time when this rule takes effect before the specified time. 148*0e209d39SAndroid Build Coastguard Worker * @param base The most recent time before this base time will be returned. 149*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 150*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 151*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 152*0e209d39SAndroid Build Coastguard Worker * standard time. 153*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 154*0e209d39SAndroid Build Coastguard Worker * @param result Receives The most recent time when this rule takes effect before 155*0e209d39SAndroid Build Coastguard Worker * the specified base time. 156*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 157*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 158*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 159*0e209d39SAndroid Build Coastguard Worker */ 160*0e209d39SAndroid Build Coastguard Worker virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 161*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const = 0; 162*0e209d39SAndroid Build Coastguard Worker 163*0e209d39SAndroid Build Coastguard Worker protected: 164*0e209d39SAndroid Build Coastguard Worker 165*0e209d39SAndroid Build Coastguard Worker /** 166*0e209d39SAndroid Build Coastguard Worker * Constructs a <code>TimeZoneRule</code> with the name, the GMT offset of its 167*0e209d39SAndroid Build Coastguard Worker * standard time and the amount of daylight saving offset adjustment. 168*0e209d39SAndroid Build Coastguard Worker * @param name The time zone name. 169*0e209d39SAndroid Build Coastguard Worker * @param rawOffset The UTC offset of its standard time in milliseconds. 170*0e209d39SAndroid Build Coastguard Worker * @param dstSavings The amount of daylight saving offset adjustment in milliseconds. 171*0e209d39SAndroid Build Coastguard Worker * If this ia a rule for standard time, the value of this argument is 0. 172*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 173*0e209d39SAndroid Build Coastguard Worker */ 174*0e209d39SAndroid Build Coastguard Worker TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings); 175*0e209d39SAndroid Build Coastguard Worker 176*0e209d39SAndroid Build Coastguard Worker /** 177*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 178*0e209d39SAndroid Build Coastguard Worker * @param source The TimeZoneRule object to be copied. 179*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 180*0e209d39SAndroid Build Coastguard Worker */ 181*0e209d39SAndroid Build Coastguard Worker TimeZoneRule(const TimeZoneRule& source); 182*0e209d39SAndroid Build Coastguard Worker 183*0e209d39SAndroid Build Coastguard Worker /** 184*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 185*0e209d39SAndroid Build Coastguard Worker * @param right The object to be copied. 186*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 187*0e209d39SAndroid Build Coastguard Worker */ 188*0e209d39SAndroid Build Coastguard Worker TimeZoneRule& operator=(const TimeZoneRule& right); 189*0e209d39SAndroid Build Coastguard Worker 190*0e209d39SAndroid Build Coastguard Worker private: 191*0e209d39SAndroid Build Coastguard Worker UnicodeString fName; // time name 192*0e209d39SAndroid Build Coastguard Worker int32_t fRawOffset; // UTC offset of the standard time in milliseconds 193*0e209d39SAndroid Build Coastguard Worker int32_t fDSTSavings; // DST saving amount in milliseconds 194*0e209d39SAndroid Build Coastguard Worker }; 195*0e209d39SAndroid Build Coastguard Worker 196*0e209d39SAndroid Build Coastguard Worker /** 197*0e209d39SAndroid Build Coastguard Worker * <code>InitialTimeZoneRule</code> represents a time zone rule 198*0e209d39SAndroid Build Coastguard Worker * representing a time zone effective from the beginning and 199*0e209d39SAndroid Build Coastguard Worker * has no actual start times. 200*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 201*0e209d39SAndroid Build Coastguard Worker */ 202*0e209d39SAndroid Build Coastguard Worker class U_I18N_API InitialTimeZoneRule : public TimeZoneRule { 203*0e209d39SAndroid Build Coastguard Worker public: 204*0e209d39SAndroid Build Coastguard Worker /** 205*0e209d39SAndroid Build Coastguard Worker * Constructs an <code>InitialTimeZoneRule</code> with the name, the GMT offset of its 206*0e209d39SAndroid Build Coastguard Worker * standard time and the amount of daylight saving offset adjustment. 207*0e209d39SAndroid Build Coastguard Worker * @param name The time zone name. 208*0e209d39SAndroid Build Coastguard Worker * @param rawOffset The UTC offset of its standard time in milliseconds. 209*0e209d39SAndroid Build Coastguard Worker * @param dstSavings The amount of daylight saving offset adjustment in milliseconds. 210*0e209d39SAndroid Build Coastguard Worker * If this ia a rule for standard time, the value of this argument is 0. 211*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 212*0e209d39SAndroid Build Coastguard Worker */ 213*0e209d39SAndroid Build Coastguard Worker InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings); 214*0e209d39SAndroid Build Coastguard Worker 215*0e209d39SAndroid Build Coastguard Worker /** 216*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 217*0e209d39SAndroid Build Coastguard Worker * @param source The InitialTimeZoneRule object to be copied. 218*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 219*0e209d39SAndroid Build Coastguard Worker */ 220*0e209d39SAndroid Build Coastguard Worker InitialTimeZoneRule(const InitialTimeZoneRule& source); 221*0e209d39SAndroid Build Coastguard Worker 222*0e209d39SAndroid Build Coastguard Worker /** 223*0e209d39SAndroid Build Coastguard Worker * Destructor. 224*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 225*0e209d39SAndroid Build Coastguard Worker */ 226*0e209d39SAndroid Build Coastguard Worker virtual ~InitialTimeZoneRule(); 227*0e209d39SAndroid Build Coastguard Worker 228*0e209d39SAndroid Build Coastguard Worker /** 229*0e209d39SAndroid Build Coastguard Worker * Clone this InitialTimeZoneRule object polymorphically. The caller owns the result and 230*0e209d39SAndroid Build Coastguard Worker * should delete it when done. 231*0e209d39SAndroid Build Coastguard Worker * @return A copy of the object. 232*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 233*0e209d39SAndroid Build Coastguard Worker */ 234*0e209d39SAndroid Build Coastguard Worker virtual InitialTimeZoneRule* clone() const override; 235*0e209d39SAndroid Build Coastguard Worker 236*0e209d39SAndroid Build Coastguard Worker /** 237*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 238*0e209d39SAndroid Build Coastguard Worker * @param right The object to be copied. 239*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 240*0e209d39SAndroid Build Coastguard Worker */ 241*0e209d39SAndroid Build Coastguard Worker InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right); 242*0e209d39SAndroid Build Coastguard Worker 243*0e209d39SAndroid Build Coastguard Worker /** 244*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 245*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 246*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 247*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 248*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 249*0e209d39SAndroid Build Coastguard Worker */ 250*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const TimeZoneRule& that) const override; 251*0e209d39SAndroid Build Coastguard Worker 252*0e209d39SAndroid Build Coastguard Worker /** 253*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 254*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 255*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 256*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 257*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 258*0e209d39SAndroid Build Coastguard Worker */ 259*0e209d39SAndroid Build Coastguard Worker virtual bool operator!=(const TimeZoneRule& that) const override; 260*0e209d39SAndroid Build Coastguard Worker 261*0e209d39SAndroid Build Coastguard Worker /** 262*0e209d39SAndroid Build Coastguard Worker * Returns if this rule represents the same rule and offsets as another. 263*0e209d39SAndroid Build Coastguard Worker * When two <code>TimeZoneRule</code> objects differ only its names, this method 264*0e209d39SAndroid Build Coastguard Worker * returns true. 265*0e209d39SAndroid Build Coastguard Worker * @param that The <code>TimeZoneRule</code> object to be compared with. 266*0e209d39SAndroid Build Coastguard Worker * @return true if the other <code>TimeZoneRule</code> is equivalent to this one. 267*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 268*0e209d39SAndroid Build Coastguard Worker */ 269*0e209d39SAndroid Build Coastguard Worker virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 270*0e209d39SAndroid Build Coastguard Worker 271*0e209d39SAndroid Build Coastguard Worker /** 272*0e209d39SAndroid Build Coastguard Worker * Gets the very first time when this rule takes effect. 273*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 274*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 275*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 276*0e209d39SAndroid Build Coastguard Worker * standard time. 277*0e209d39SAndroid Build Coastguard Worker * @param result Receives the very first time when this rule takes effect. 278*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 279*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 280*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 281*0e209d39SAndroid Build Coastguard Worker */ 282*0e209d39SAndroid Build Coastguard Worker virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 283*0e209d39SAndroid Build Coastguard Worker 284*0e209d39SAndroid Build Coastguard Worker /** 285*0e209d39SAndroid Build Coastguard Worker * Gets the final time when this rule takes effect. 286*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 287*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 288*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 289*0e209d39SAndroid Build Coastguard Worker * standard time. 290*0e209d39SAndroid Build Coastguard Worker * @param result Receives the final time when this rule takes effect. 291*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 292*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 293*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 294*0e209d39SAndroid Build Coastguard Worker */ 295*0e209d39SAndroid Build Coastguard Worker virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 296*0e209d39SAndroid Build Coastguard Worker 297*0e209d39SAndroid Build Coastguard Worker /** 298*0e209d39SAndroid Build Coastguard Worker * Gets the first time when this rule takes effect after the specified time. 299*0e209d39SAndroid Build Coastguard Worker * @param base The first start time after this base time will be returned. 300*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 301*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 302*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 303*0e209d39SAndroid Build Coastguard Worker * standard time. 304*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 305*0e209d39SAndroid Build Coastguard Worker * @param result Receives The first time when this rule takes effect after 306*0e209d39SAndroid Build Coastguard Worker * the specified base time. 307*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 308*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 309*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 310*0e209d39SAndroid Build Coastguard Worker */ 311*0e209d39SAndroid Build Coastguard Worker virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 312*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const override; 313*0e209d39SAndroid Build Coastguard Worker 314*0e209d39SAndroid Build Coastguard Worker /** 315*0e209d39SAndroid Build Coastguard Worker * Gets the most recent time when this rule takes effect before the specified time. 316*0e209d39SAndroid Build Coastguard Worker * @param base The most recent time before this base time will be returned. 317*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 318*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 319*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 320*0e209d39SAndroid Build Coastguard Worker * standard time. 321*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 322*0e209d39SAndroid Build Coastguard Worker * @param result Receives The most recent time when this rule takes effect before 323*0e209d39SAndroid Build Coastguard Worker * the specified base time. 324*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 325*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 326*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 327*0e209d39SAndroid Build Coastguard Worker */ 328*0e209d39SAndroid Build Coastguard Worker virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 329*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const override; 330*0e209d39SAndroid Build Coastguard Worker 331*0e209d39SAndroid Build Coastguard Worker public: 332*0e209d39SAndroid Build Coastguard Worker /** 333*0e209d39SAndroid Build Coastguard Worker * Return the class ID for this class. This is useful only for comparing to 334*0e209d39SAndroid Build Coastguard Worker * a return value from getDynamicClassID(). For example: 335*0e209d39SAndroid Build Coastguard Worker * <pre> 336*0e209d39SAndroid Build Coastguard Worker * . Base* polymorphic_pointer = createPolymorphicObject(); 337*0e209d39SAndroid Build Coastguard Worker * . if (polymorphic_pointer->getDynamicClassID() == 338*0e209d39SAndroid Build Coastguard Worker * . erived::getStaticClassID()) ... 339*0e209d39SAndroid Build Coastguard Worker * </pre> 340*0e209d39SAndroid Build Coastguard Worker * @return The class ID for all objects of this class. 341*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 342*0e209d39SAndroid Build Coastguard Worker */ 343*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 344*0e209d39SAndroid Build Coastguard Worker 345*0e209d39SAndroid Build Coastguard Worker /** 346*0e209d39SAndroid Build Coastguard Worker * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 347*0e209d39SAndroid Build Coastguard Worker * method is to implement a simple version of RTTI, since not all C++ 348*0e209d39SAndroid Build Coastguard Worker * compilers support genuine RTTI. Polymorphic operator==() and clone() 349*0e209d39SAndroid Build Coastguard Worker * methods call this method. 350*0e209d39SAndroid Build Coastguard Worker * 351*0e209d39SAndroid Build Coastguard Worker * @return The class ID for this object. All objects of a 352*0e209d39SAndroid Build Coastguard Worker * given class have the same class ID. Objects of 353*0e209d39SAndroid Build Coastguard Worker * other classes have different class IDs. 354*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 355*0e209d39SAndroid Build Coastguard Worker */ 356*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 357*0e209d39SAndroid Build Coastguard Worker }; 358*0e209d39SAndroid Build Coastguard Worker 359*0e209d39SAndroid Build Coastguard Worker /** 360*0e209d39SAndroid Build Coastguard Worker * <code>AnnualTimeZoneRule</code> is a class used for representing a time zone 361*0e209d39SAndroid Build Coastguard Worker * rule which takes effect annually. The calendar system used for the rule is 362*0e209d39SAndroid Build Coastguard Worker * is based on Gregorian calendar 363*0e209d39SAndroid Build Coastguard Worker * 364*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 365*0e209d39SAndroid Build Coastguard Worker */ 366*0e209d39SAndroid Build Coastguard Worker class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule { 367*0e209d39SAndroid Build Coastguard Worker public: 368*0e209d39SAndroid Build Coastguard Worker /** 369*0e209d39SAndroid Build Coastguard Worker * The constant representing the maximum year used for designating 370*0e209d39SAndroid Build Coastguard Worker * a rule is permanent. 371*0e209d39SAndroid Build Coastguard Worker */ 372*0e209d39SAndroid Build Coastguard Worker static const int32_t MAX_YEAR; 373*0e209d39SAndroid Build Coastguard Worker 374*0e209d39SAndroid Build Coastguard Worker /** 375*0e209d39SAndroid Build Coastguard Worker * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its 376*0e209d39SAndroid Build Coastguard Worker * standard time, the amount of daylight saving offset adjustment, the annual start 377*0e209d39SAndroid Build Coastguard Worker * time rule and the start/until years. The input DateTimeRule is copied by this 378*0e209d39SAndroid Build Coastguard Worker * constructor, so the caller remains responsible for deleting the object. 379*0e209d39SAndroid Build Coastguard Worker * @param name The time zone name. 380*0e209d39SAndroid Build Coastguard Worker * @param rawOffset The GMT offset of its standard time in milliseconds. 381*0e209d39SAndroid Build Coastguard Worker * @param dstSavings The amount of daylight saving offset adjustment in 382*0e209d39SAndroid Build Coastguard Worker * milliseconds. If this ia a rule for standard time, 383*0e209d39SAndroid Build Coastguard Worker * the value of this argument is 0. 384*0e209d39SAndroid Build Coastguard Worker * @param dateTimeRule The start date/time rule repeated annually. 385*0e209d39SAndroid Build Coastguard Worker * @param startYear The first year when this rule takes effect. 386*0e209d39SAndroid Build Coastguard Worker * @param endYear The last year when this rule takes effect. If this 387*0e209d39SAndroid Build Coastguard Worker * rule is effective forever in future, specify MAX_YEAR. 388*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 389*0e209d39SAndroid Build Coastguard Worker */ 390*0e209d39SAndroid Build Coastguard Worker AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 391*0e209d39SAndroid Build Coastguard Worker const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear); 392*0e209d39SAndroid Build Coastguard Worker 393*0e209d39SAndroid Build Coastguard Worker /** 394*0e209d39SAndroid Build Coastguard Worker * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its 395*0e209d39SAndroid Build Coastguard Worker * standard time, the amount of daylight saving offset adjustment, the annual start 396*0e209d39SAndroid Build Coastguard Worker * time rule and the start/until years. The input DateTimeRule object is adopted 397*0e209d39SAndroid Build Coastguard Worker * by this object, therefore, the caller must not delete the object. 398*0e209d39SAndroid Build Coastguard Worker * @param name The time zone name. 399*0e209d39SAndroid Build Coastguard Worker * @param rawOffset The GMT offset of its standard time in milliseconds. 400*0e209d39SAndroid Build Coastguard Worker * @param dstSavings The amount of daylight saving offset adjustment in 401*0e209d39SAndroid Build Coastguard Worker * milliseconds. If this ia a rule for standard time, 402*0e209d39SAndroid Build Coastguard Worker * the value of this argument is 0. 403*0e209d39SAndroid Build Coastguard Worker * @param dateTimeRule The start date/time rule repeated annually. 404*0e209d39SAndroid Build Coastguard Worker * @param startYear The first year when this rule takes effect. 405*0e209d39SAndroid Build Coastguard Worker * @param endYear The last year when this rule takes effect. If this 406*0e209d39SAndroid Build Coastguard Worker * rule is effective forever in future, specify MAX_YEAR. 407*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 408*0e209d39SAndroid Build Coastguard Worker */ 409*0e209d39SAndroid Build Coastguard Worker AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 410*0e209d39SAndroid Build Coastguard Worker DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear); 411*0e209d39SAndroid Build Coastguard Worker 412*0e209d39SAndroid Build Coastguard Worker /** 413*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 414*0e209d39SAndroid Build Coastguard Worker * @param source The AnnualTimeZoneRule object to be copied. 415*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 416*0e209d39SAndroid Build Coastguard Worker */ 417*0e209d39SAndroid Build Coastguard Worker AnnualTimeZoneRule(const AnnualTimeZoneRule& source); 418*0e209d39SAndroid Build Coastguard Worker 419*0e209d39SAndroid Build Coastguard Worker /** 420*0e209d39SAndroid Build Coastguard Worker * Destructor. 421*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 422*0e209d39SAndroid Build Coastguard Worker */ 423*0e209d39SAndroid Build Coastguard Worker virtual ~AnnualTimeZoneRule(); 424*0e209d39SAndroid Build Coastguard Worker 425*0e209d39SAndroid Build Coastguard Worker /** 426*0e209d39SAndroid Build Coastguard Worker * Clone this AnnualTimeZoneRule object polymorphically. The caller owns the result and 427*0e209d39SAndroid Build Coastguard Worker * should delete it when done. 428*0e209d39SAndroid Build Coastguard Worker * @return A copy of the object. 429*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 430*0e209d39SAndroid Build Coastguard Worker */ 431*0e209d39SAndroid Build Coastguard Worker virtual AnnualTimeZoneRule* clone() const override; 432*0e209d39SAndroid Build Coastguard Worker 433*0e209d39SAndroid Build Coastguard Worker /** 434*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 435*0e209d39SAndroid Build Coastguard Worker * @param right The object to be copied. 436*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 437*0e209d39SAndroid Build Coastguard Worker */ 438*0e209d39SAndroid Build Coastguard Worker AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right); 439*0e209d39SAndroid Build Coastguard Worker 440*0e209d39SAndroid Build Coastguard Worker /** 441*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 442*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 443*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 444*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 445*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 446*0e209d39SAndroid Build Coastguard Worker */ 447*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const TimeZoneRule& that) const override; 448*0e209d39SAndroid Build Coastguard Worker 449*0e209d39SAndroid Build Coastguard Worker /** 450*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 451*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 452*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 453*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 454*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 455*0e209d39SAndroid Build Coastguard Worker */ 456*0e209d39SAndroid Build Coastguard Worker virtual bool operator!=(const TimeZoneRule& that) const override; 457*0e209d39SAndroid Build Coastguard Worker 458*0e209d39SAndroid Build Coastguard Worker /** 459*0e209d39SAndroid Build Coastguard Worker * Gets the start date/time rule used by this rule. 460*0e209d39SAndroid Build Coastguard Worker * @return The <code>AnnualDateTimeRule</code> which represents the start date/time 461*0e209d39SAndroid Build Coastguard Worker * rule used by this time zone rule. 462*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 463*0e209d39SAndroid Build Coastguard Worker */ 464*0e209d39SAndroid Build Coastguard Worker const DateTimeRule* getRule() const; 465*0e209d39SAndroid Build Coastguard Worker 466*0e209d39SAndroid Build Coastguard Worker /** 467*0e209d39SAndroid Build Coastguard Worker * Gets the first year when this rule takes effect. 468*0e209d39SAndroid Build Coastguard Worker * @return The start year of this rule. The year is in Gregorian calendar 469*0e209d39SAndroid Build Coastguard Worker * with 0 == 1 BCE, -1 == 2 BCE, etc. 470*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 471*0e209d39SAndroid Build Coastguard Worker */ 472*0e209d39SAndroid Build Coastguard Worker int32_t getStartYear() const; 473*0e209d39SAndroid Build Coastguard Worker 474*0e209d39SAndroid Build Coastguard Worker /** 475*0e209d39SAndroid Build Coastguard Worker * Gets the end year when this rule takes effect. 476*0e209d39SAndroid Build Coastguard Worker * @return The end year of this rule (inclusive). The year is in Gregorian calendar 477*0e209d39SAndroid Build Coastguard Worker * with 0 == 1 BCE, -1 == 2 BCE, etc. 478*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 479*0e209d39SAndroid Build Coastguard Worker */ 480*0e209d39SAndroid Build Coastguard Worker int32_t getEndYear() const; 481*0e209d39SAndroid Build Coastguard Worker 482*0e209d39SAndroid Build Coastguard Worker /** 483*0e209d39SAndroid Build Coastguard Worker * Gets the time when this rule takes effect in the given year. 484*0e209d39SAndroid Build Coastguard Worker * @param year The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. 485*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 486*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 487*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 488*0e209d39SAndroid Build Coastguard Worker * standard time. 489*0e209d39SAndroid Build Coastguard Worker * @param result Receives the start time in the year. 490*0e209d39SAndroid Build Coastguard Worker * @return true if this rule takes effect in the year and the result is set to 491*0e209d39SAndroid Build Coastguard Worker * "result". 492*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 493*0e209d39SAndroid Build Coastguard Worker */ 494*0e209d39SAndroid Build Coastguard Worker UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const; 495*0e209d39SAndroid Build Coastguard Worker 496*0e209d39SAndroid Build Coastguard Worker /** 497*0e209d39SAndroid Build Coastguard Worker * Returns if this rule represents the same rule and offsets as another. 498*0e209d39SAndroid Build Coastguard Worker * When two <code>TimeZoneRule</code> objects differ only its names, this method 499*0e209d39SAndroid Build Coastguard Worker * returns true. 500*0e209d39SAndroid Build Coastguard Worker * @param that The <code>TimeZoneRule</code> object to be compared with. 501*0e209d39SAndroid Build Coastguard Worker * @return true if the other <code>TimeZoneRule</code> is equivalent to this one. 502*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 503*0e209d39SAndroid Build Coastguard Worker */ 504*0e209d39SAndroid Build Coastguard Worker virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 505*0e209d39SAndroid Build Coastguard Worker 506*0e209d39SAndroid Build Coastguard Worker /** 507*0e209d39SAndroid Build Coastguard Worker * Gets the very first time when this rule takes effect. 508*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 509*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 510*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 511*0e209d39SAndroid Build Coastguard Worker * standard time. 512*0e209d39SAndroid Build Coastguard Worker * @param result Receives the very first time when this rule takes effect. 513*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 514*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 515*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 516*0e209d39SAndroid Build Coastguard Worker */ 517*0e209d39SAndroid Build Coastguard Worker virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 518*0e209d39SAndroid Build Coastguard Worker 519*0e209d39SAndroid Build Coastguard Worker /** 520*0e209d39SAndroid Build Coastguard Worker * Gets the final time when this rule takes effect. 521*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 522*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 523*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 524*0e209d39SAndroid Build Coastguard Worker * standard time. 525*0e209d39SAndroid Build Coastguard Worker * @param result Receives the final time when this rule takes effect. 526*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 527*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 528*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 529*0e209d39SAndroid Build Coastguard Worker */ 530*0e209d39SAndroid Build Coastguard Worker virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 531*0e209d39SAndroid Build Coastguard Worker 532*0e209d39SAndroid Build Coastguard Worker /** 533*0e209d39SAndroid Build Coastguard Worker * Gets the first time when this rule takes effect after the specified time. 534*0e209d39SAndroid Build Coastguard Worker * @param base The first start time after this base time will be returned. 535*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 536*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 537*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 538*0e209d39SAndroid Build Coastguard Worker * standard time. 539*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 540*0e209d39SAndroid Build Coastguard Worker * @param result Receives The first time when this rule takes effect after 541*0e209d39SAndroid Build Coastguard Worker * the specified base time. 542*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 543*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 544*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 545*0e209d39SAndroid Build Coastguard Worker */ 546*0e209d39SAndroid Build Coastguard Worker virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 547*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const override; 548*0e209d39SAndroid Build Coastguard Worker 549*0e209d39SAndroid Build Coastguard Worker /** 550*0e209d39SAndroid Build Coastguard Worker * Gets the most recent time when this rule takes effect before the specified time. 551*0e209d39SAndroid Build Coastguard Worker * @param base The most recent time before this base time will be returned. 552*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 553*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 554*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 555*0e209d39SAndroid Build Coastguard Worker * standard time. 556*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 557*0e209d39SAndroid Build Coastguard Worker * @param result Receives The most recent time when this rule takes effect before 558*0e209d39SAndroid Build Coastguard Worker * the specified base time. 559*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 560*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 561*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 562*0e209d39SAndroid Build Coastguard Worker */ 563*0e209d39SAndroid Build Coastguard Worker virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 564*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const override; 565*0e209d39SAndroid Build Coastguard Worker 566*0e209d39SAndroid Build Coastguard Worker 567*0e209d39SAndroid Build Coastguard Worker private: 568*0e209d39SAndroid Build Coastguard Worker DateTimeRule* fDateTimeRule; 569*0e209d39SAndroid Build Coastguard Worker int32_t fStartYear; 570*0e209d39SAndroid Build Coastguard Worker int32_t fEndYear; 571*0e209d39SAndroid Build Coastguard Worker 572*0e209d39SAndroid Build Coastguard Worker public: 573*0e209d39SAndroid Build Coastguard Worker /** 574*0e209d39SAndroid Build Coastguard Worker * Return the class ID for this class. This is useful only for comparing to 575*0e209d39SAndroid Build Coastguard Worker * a return value from getDynamicClassID(). For example: 576*0e209d39SAndroid Build Coastguard Worker * <pre> 577*0e209d39SAndroid Build Coastguard Worker * . Base* polymorphic_pointer = createPolymorphicObject(); 578*0e209d39SAndroid Build Coastguard Worker * . if (polymorphic_pointer->getDynamicClassID() == 579*0e209d39SAndroid Build Coastguard Worker * . erived::getStaticClassID()) ... 580*0e209d39SAndroid Build Coastguard Worker * </pre> 581*0e209d39SAndroid Build Coastguard Worker * @return The class ID for all objects of this class. 582*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 583*0e209d39SAndroid Build Coastguard Worker */ 584*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 585*0e209d39SAndroid Build Coastguard Worker 586*0e209d39SAndroid Build Coastguard Worker /** 587*0e209d39SAndroid Build Coastguard Worker * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 588*0e209d39SAndroid Build Coastguard Worker * method is to implement a simple version of RTTI, since not all C++ 589*0e209d39SAndroid Build Coastguard Worker * compilers support genuine RTTI. Polymorphic operator==() and clone() 590*0e209d39SAndroid Build Coastguard Worker * methods call this method. 591*0e209d39SAndroid Build Coastguard Worker * 592*0e209d39SAndroid Build Coastguard Worker * @return The class ID for this object. All objects of a 593*0e209d39SAndroid Build Coastguard Worker * given class have the same class ID. Objects of 594*0e209d39SAndroid Build Coastguard Worker * other classes have different class IDs. 595*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 596*0e209d39SAndroid Build Coastguard Worker */ 597*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 598*0e209d39SAndroid Build Coastguard Worker }; 599*0e209d39SAndroid Build Coastguard Worker 600*0e209d39SAndroid Build Coastguard Worker /** 601*0e209d39SAndroid Build Coastguard Worker * <code>TimeArrayTimeZoneRule</code> represents a time zone rule whose start times are 602*0e209d39SAndroid Build Coastguard Worker * defined by an array of milliseconds since the standard base time. 603*0e209d39SAndroid Build Coastguard Worker * 604*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 605*0e209d39SAndroid Build Coastguard Worker */ 606*0e209d39SAndroid Build Coastguard Worker class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule { 607*0e209d39SAndroid Build Coastguard Worker public: 608*0e209d39SAndroid Build Coastguard Worker /** 609*0e209d39SAndroid Build Coastguard Worker * Constructs a <code>TimeArrayTimeZoneRule</code> with the name, the GMT offset of its 610*0e209d39SAndroid Build Coastguard Worker * standard time, the amount of daylight saving offset adjustment and 611*0e209d39SAndroid Build Coastguard Worker * the array of times when this rule takes effect. 612*0e209d39SAndroid Build Coastguard Worker * @param name The time zone name. 613*0e209d39SAndroid Build Coastguard Worker * @param rawOffset The UTC offset of its standard time in milliseconds. 614*0e209d39SAndroid Build Coastguard Worker * @param dstSavings The amount of daylight saving offset adjustment in 615*0e209d39SAndroid Build Coastguard Worker * milliseconds. If this ia a rule for standard time, 616*0e209d39SAndroid Build Coastguard Worker * the value of this argument is 0. 617*0e209d39SAndroid Build Coastguard Worker * @param startTimes The array start times in milliseconds since the base time 618*0e209d39SAndroid Build Coastguard Worker * (January 1, 1970, 00:00:00). 619*0e209d39SAndroid Build Coastguard Worker * @param numStartTimes The number of elements in the parameter "startTimes" 620*0e209d39SAndroid Build Coastguard Worker * @param timeRuleType The time type of the start times, which is one of 621*0e209d39SAndroid Build Coastguard Worker * <code>DataTimeRule::WALL_TIME</code>, <code>STANDARD_TIME</code> 622*0e209d39SAndroid Build Coastguard Worker * and <code>UTC_TIME</code>. 623*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 624*0e209d39SAndroid Build Coastguard Worker */ 625*0e209d39SAndroid Build Coastguard Worker TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 626*0e209d39SAndroid Build Coastguard Worker const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType); 627*0e209d39SAndroid Build Coastguard Worker 628*0e209d39SAndroid Build Coastguard Worker /** 629*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 630*0e209d39SAndroid Build Coastguard Worker * @param source The TimeArrayTimeZoneRule object to be copied. 631*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 632*0e209d39SAndroid Build Coastguard Worker */ 633*0e209d39SAndroid Build Coastguard Worker TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source); 634*0e209d39SAndroid Build Coastguard Worker 635*0e209d39SAndroid Build Coastguard Worker /** 636*0e209d39SAndroid Build Coastguard Worker * Destructor. 637*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 638*0e209d39SAndroid Build Coastguard Worker */ 639*0e209d39SAndroid Build Coastguard Worker virtual ~TimeArrayTimeZoneRule(); 640*0e209d39SAndroid Build Coastguard Worker 641*0e209d39SAndroid Build Coastguard Worker /** 642*0e209d39SAndroid Build Coastguard Worker * Clone this TimeArrayTimeZoneRule object polymorphically. The caller owns the result and 643*0e209d39SAndroid Build Coastguard Worker * should delete it when done. 644*0e209d39SAndroid Build Coastguard Worker * @return A copy of the object. 645*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 646*0e209d39SAndroid Build Coastguard Worker */ 647*0e209d39SAndroid Build Coastguard Worker virtual TimeArrayTimeZoneRule* clone() const override; 648*0e209d39SAndroid Build Coastguard Worker 649*0e209d39SAndroid Build Coastguard Worker /** 650*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 651*0e209d39SAndroid Build Coastguard Worker * @param right The object to be copied. 652*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 653*0e209d39SAndroid Build Coastguard Worker */ 654*0e209d39SAndroid Build Coastguard Worker TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right); 655*0e209d39SAndroid Build Coastguard Worker 656*0e209d39SAndroid Build Coastguard Worker /** 657*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 658*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 659*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 660*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 661*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 662*0e209d39SAndroid Build Coastguard Worker */ 663*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const TimeZoneRule& that) const override; 664*0e209d39SAndroid Build Coastguard Worker 665*0e209d39SAndroid Build Coastguard Worker /** 666*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 667*0e209d39SAndroid Build Coastguard Worker * of different subclasses are considered unequal. 668*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 669*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 670*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 671*0e209d39SAndroid Build Coastguard Worker */ 672*0e209d39SAndroid Build Coastguard Worker virtual bool operator!=(const TimeZoneRule& that) const override; 673*0e209d39SAndroid Build Coastguard Worker 674*0e209d39SAndroid Build Coastguard Worker /** 675*0e209d39SAndroid Build Coastguard Worker * Gets the time type of the start times used by this rule. The return value 676*0e209d39SAndroid Build Coastguard Worker * is either <code>DateTimeRule::WALL_TIME</code> or <code>STANDARD_TIME</code> 677*0e209d39SAndroid Build Coastguard Worker * or <code>UTC_TIME</code>. 678*0e209d39SAndroid Build Coastguard Worker * 679*0e209d39SAndroid Build Coastguard Worker * @return The time type used of the start times used by this rule. 680*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 681*0e209d39SAndroid Build Coastguard Worker */ 682*0e209d39SAndroid Build Coastguard Worker DateTimeRule::TimeRuleType getTimeType() const; 683*0e209d39SAndroid Build Coastguard Worker 684*0e209d39SAndroid Build Coastguard Worker /** 685*0e209d39SAndroid Build Coastguard Worker * Gets a start time at the index stored in this rule. 686*0e209d39SAndroid Build Coastguard Worker * @param index The index of start times 687*0e209d39SAndroid Build Coastguard Worker * @param result Receives the start time at the index 688*0e209d39SAndroid Build Coastguard Worker * @return true if the index is within the valid range and 689*0e209d39SAndroid Build Coastguard Worker * and the result is set. When false, the output 690*0e209d39SAndroid Build Coastguard Worker * parameger "result" is unchanged. 691*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 692*0e209d39SAndroid Build Coastguard Worker */ 693*0e209d39SAndroid Build Coastguard Worker UBool getStartTimeAt(int32_t index, UDate& result) const; 694*0e209d39SAndroid Build Coastguard Worker 695*0e209d39SAndroid Build Coastguard Worker /** 696*0e209d39SAndroid Build Coastguard Worker * Returns the number of start times stored in this rule 697*0e209d39SAndroid Build Coastguard Worker * @return The number of start times. 698*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 699*0e209d39SAndroid Build Coastguard Worker */ 700*0e209d39SAndroid Build Coastguard Worker int32_t countStartTimes() const; 701*0e209d39SAndroid Build Coastguard Worker 702*0e209d39SAndroid Build Coastguard Worker /** 703*0e209d39SAndroid Build Coastguard Worker * Returns if this rule represents the same rule and offsets as another. 704*0e209d39SAndroid Build Coastguard Worker * When two <code>TimeZoneRule</code> objects differ only its names, this method 705*0e209d39SAndroid Build Coastguard Worker * returns true. 706*0e209d39SAndroid Build Coastguard Worker * @param that The <code>TimeZoneRule</code> object to be compared with. 707*0e209d39SAndroid Build Coastguard Worker * @return true if the other <code>TimeZoneRule</code> is equivalent to this one. 708*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 709*0e209d39SAndroid Build Coastguard Worker */ 710*0e209d39SAndroid Build Coastguard Worker virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 711*0e209d39SAndroid Build Coastguard Worker 712*0e209d39SAndroid Build Coastguard Worker /** 713*0e209d39SAndroid Build Coastguard Worker * Gets the very first time when this rule takes effect. 714*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 715*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 716*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 717*0e209d39SAndroid Build Coastguard Worker * standard time. 718*0e209d39SAndroid Build Coastguard Worker * @param result Receives the very first time when this rule takes effect. 719*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 720*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 721*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 722*0e209d39SAndroid Build Coastguard Worker */ 723*0e209d39SAndroid Build Coastguard Worker virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 724*0e209d39SAndroid Build Coastguard Worker 725*0e209d39SAndroid Build Coastguard Worker /** 726*0e209d39SAndroid Build Coastguard Worker * Gets the final time when this rule takes effect. 727*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 728*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 729*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 730*0e209d39SAndroid Build Coastguard Worker * standard time. 731*0e209d39SAndroid Build Coastguard Worker * @param result Receives the final time when this rule takes effect. 732*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 733*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 734*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 735*0e209d39SAndroid Build Coastguard Worker */ 736*0e209d39SAndroid Build Coastguard Worker virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 737*0e209d39SAndroid Build Coastguard Worker 738*0e209d39SAndroid Build Coastguard Worker /** 739*0e209d39SAndroid Build Coastguard Worker * Gets the first time when this rule takes effect after the specified time. 740*0e209d39SAndroid Build Coastguard Worker * @param base The first start time after this base time will be returned. 741*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 742*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 743*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 744*0e209d39SAndroid Build Coastguard Worker * standard time. 745*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 746*0e209d39SAndroid Build Coastguard Worker * @param result Receives The first time when this rule takes effect after 747*0e209d39SAndroid Build Coastguard Worker * the specified base time. 748*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 749*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 750*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 751*0e209d39SAndroid Build Coastguard Worker */ 752*0e209d39SAndroid Build Coastguard Worker virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 753*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const override; 754*0e209d39SAndroid Build Coastguard Worker 755*0e209d39SAndroid Build Coastguard Worker /** 756*0e209d39SAndroid Build Coastguard Worker * Gets the most recent time when this rule takes effect before the specified time. 757*0e209d39SAndroid Build Coastguard Worker * @param base The most recent time before this base time will be returned. 758*0e209d39SAndroid Build Coastguard Worker * @param prevRawOffset The standard time offset from UTC before this rule 759*0e209d39SAndroid Build Coastguard Worker * takes effect in milliseconds. 760*0e209d39SAndroid Build Coastguard Worker * @param prevDSTSavings The amount of daylight saving offset from the 761*0e209d39SAndroid Build Coastguard Worker * standard time. 762*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 763*0e209d39SAndroid Build Coastguard Worker * @param result Receives The most recent time when this rule takes effect before 764*0e209d39SAndroid Build Coastguard Worker * the specified base time. 765*0e209d39SAndroid Build Coastguard Worker * @return true if the start time is available. When false is returned, output parameter 766*0e209d39SAndroid Build Coastguard Worker * "result" is unchanged. 767*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 768*0e209d39SAndroid Build Coastguard Worker */ 769*0e209d39SAndroid Build Coastguard Worker virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 770*0e209d39SAndroid Build Coastguard Worker UBool inclusive, UDate& result) const override; 771*0e209d39SAndroid Build Coastguard Worker 772*0e209d39SAndroid Build Coastguard Worker 773*0e209d39SAndroid Build Coastguard Worker private: 774*0e209d39SAndroid Build Coastguard Worker enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 }; 775*0e209d39SAndroid Build Coastguard Worker UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec); 776*0e209d39SAndroid Build Coastguard Worker UDate getUTC(UDate time, int32_t raw, int32_t dst) const; 777*0e209d39SAndroid Build Coastguard Worker 778*0e209d39SAndroid Build Coastguard Worker DateTimeRule::TimeRuleType fTimeRuleType; 779*0e209d39SAndroid Build Coastguard Worker int32_t fNumStartTimes; 780*0e209d39SAndroid Build Coastguard Worker UDate* fStartTimes; 781*0e209d39SAndroid Build Coastguard Worker UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE]; 782*0e209d39SAndroid Build Coastguard Worker 783*0e209d39SAndroid Build Coastguard Worker public: 784*0e209d39SAndroid Build Coastguard Worker /** 785*0e209d39SAndroid Build Coastguard Worker * Return the class ID for this class. This is useful only for comparing to 786*0e209d39SAndroid Build Coastguard Worker * a return value from getDynamicClassID(). For example: 787*0e209d39SAndroid Build Coastguard Worker * <pre> 788*0e209d39SAndroid Build Coastguard Worker * . Base* polymorphic_pointer = createPolymorphicObject(); 789*0e209d39SAndroid Build Coastguard Worker * . if (polymorphic_pointer->getDynamicClassID() == 790*0e209d39SAndroid Build Coastguard Worker * . erived::getStaticClassID()) ... 791*0e209d39SAndroid Build Coastguard Worker * </pre> 792*0e209d39SAndroid Build Coastguard Worker * @return The class ID for all objects of this class. 793*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 794*0e209d39SAndroid Build Coastguard Worker */ 795*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 796*0e209d39SAndroid Build Coastguard Worker 797*0e209d39SAndroid Build Coastguard Worker /** 798*0e209d39SAndroid Build Coastguard Worker * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 799*0e209d39SAndroid Build Coastguard Worker * method is to implement a simple version of RTTI, since not all C++ 800*0e209d39SAndroid Build Coastguard Worker * compilers support genuine RTTI. Polymorphic operator==() and clone() 801*0e209d39SAndroid Build Coastguard Worker * methods call this method. 802*0e209d39SAndroid Build Coastguard Worker * 803*0e209d39SAndroid Build Coastguard Worker * @return The class ID for this object. All objects of a 804*0e209d39SAndroid Build Coastguard Worker * given class have the same class ID. Objects of 805*0e209d39SAndroid Build Coastguard Worker * other classes have different class IDs. 806*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 807*0e209d39SAndroid Build Coastguard Worker */ 808*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 809*0e209d39SAndroid Build Coastguard Worker }; 810*0e209d39SAndroid Build Coastguard Worker 811*0e209d39SAndroid Build Coastguard Worker 812*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 813*0e209d39SAndroid Build Coastguard Worker 814*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 815*0e209d39SAndroid Build Coastguard Worker 816*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */ 817*0e209d39SAndroid Build Coastguard Worker 818*0e209d39SAndroid Build Coastguard Worker #endif // TZRULE_H 819*0e209d39SAndroid Build Coastguard Worker 820*0e209d39SAndroid Build Coastguard Worker //eof 821