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-2013, 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 RBTZ_H 10*0e209d39SAndroid Build Coastguard Worker #define RBTZ_H 11*0e209d39SAndroid Build Coastguard Worker 12*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 13*0e209d39SAndroid Build Coastguard Worker 14*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 15*0e209d39SAndroid Build Coastguard Worker 16*0e209d39SAndroid Build Coastguard Worker /** 17*0e209d39SAndroid Build Coastguard Worker * \file 18*0e209d39SAndroid Build Coastguard Worker * \brief C++ API: Rule based customizable time zone 19*0e209d39SAndroid Build Coastguard Worker */ 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/basictz.h" 24*0e209d39SAndroid Build Coastguard Worker #include "unicode/unistr.h" 25*0e209d39SAndroid Build Coastguard Worker 26*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 27*0e209d39SAndroid Build Coastguard Worker 28*0e209d39SAndroid Build Coastguard Worker // forward declaration 29*0e209d39SAndroid Build Coastguard Worker class UVector; 30*0e209d39SAndroid Build Coastguard Worker struct Transition; 31*0e209d39SAndroid Build Coastguard Worker 32*0e209d39SAndroid Build Coastguard Worker /** 33*0e209d39SAndroid Build Coastguard Worker * a BasicTimeZone subclass implemented in terms of InitialTimeZoneRule and TimeZoneRule instances 34*0e209d39SAndroid Build Coastguard Worker * @see BasicTimeZone 35*0e209d39SAndroid Build Coastguard Worker * @see InitialTimeZoneRule 36*0e209d39SAndroid Build Coastguard Worker * @see TimeZoneRule 37*0e209d39SAndroid Build Coastguard Worker */ 38*0e209d39SAndroid Build Coastguard Worker class U_I18N_API RuleBasedTimeZone : public BasicTimeZone { 39*0e209d39SAndroid Build Coastguard Worker public: 40*0e209d39SAndroid Build Coastguard Worker /** 41*0e209d39SAndroid Build Coastguard Worker * Constructs a <code>RuleBasedTimeZone</code> object with the ID and the 42*0e209d39SAndroid Build Coastguard Worker * <code>InitialTimeZoneRule</code>. The input <code>InitialTimeZoneRule</code> 43*0e209d39SAndroid Build Coastguard Worker * is adopted by this <code>RuleBasedTimeZone</code>, thus the caller must not 44*0e209d39SAndroid Build Coastguard Worker * delete it. 45*0e209d39SAndroid Build Coastguard Worker * @param id The time zone ID. 46*0e209d39SAndroid Build Coastguard Worker * @param initialRule The initial time zone rule. 47*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 48*0e209d39SAndroid Build Coastguard Worker */ 49*0e209d39SAndroid Build Coastguard Worker RuleBasedTimeZone(const UnicodeString& id, InitialTimeZoneRule* initialRule); 50*0e209d39SAndroid Build Coastguard Worker 51*0e209d39SAndroid Build Coastguard Worker /** 52*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 53*0e209d39SAndroid Build Coastguard Worker * @param source The RuleBasedTimeZone object to be copied. 54*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 55*0e209d39SAndroid Build Coastguard Worker */ 56*0e209d39SAndroid Build Coastguard Worker RuleBasedTimeZone(const RuleBasedTimeZone& source); 57*0e209d39SAndroid Build Coastguard Worker 58*0e209d39SAndroid Build Coastguard Worker /** 59*0e209d39SAndroid Build Coastguard Worker * Destructor. 60*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 61*0e209d39SAndroid Build Coastguard Worker */ 62*0e209d39SAndroid Build Coastguard Worker virtual ~RuleBasedTimeZone(); 63*0e209d39SAndroid Build Coastguard Worker 64*0e209d39SAndroid Build Coastguard Worker /** 65*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 66*0e209d39SAndroid Build Coastguard Worker * @param right The object to be copied. 67*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 68*0e209d39SAndroid Build Coastguard Worker */ 69*0e209d39SAndroid Build Coastguard Worker RuleBasedTimeZone& operator=(const RuleBasedTimeZone& right); 70*0e209d39SAndroid Build Coastguard Worker 71*0e209d39SAndroid Build Coastguard Worker /** 72*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZone</code> objects are 73*0e209d39SAndroid Build Coastguard Worker * semantically equal. Objects of different subclasses are considered unequal. 74*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 75*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZone</code> objects are 76*0e209d39SAndroid Build Coastguard Worker *semantically equal. 77*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 78*0e209d39SAndroid Build Coastguard Worker */ 79*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const TimeZone& that) const override; 80*0e209d39SAndroid Build Coastguard Worker 81*0e209d39SAndroid Build Coastguard Worker /** 82*0e209d39SAndroid Build Coastguard Worker * Return true if the given <code>TimeZone</code> objects are 83*0e209d39SAndroid Build Coastguard Worker * semantically unequal. Objects of different subclasses are considered unequal. 84*0e209d39SAndroid Build Coastguard Worker * @param that The object to be compared with. 85*0e209d39SAndroid Build Coastguard Worker * @return true if the given <code>TimeZone</code> objects are 86*0e209d39SAndroid Build Coastguard Worker * semantically unequal. 87*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 88*0e209d39SAndroid Build Coastguard Worker */ 89*0e209d39SAndroid Build Coastguard Worker virtual bool operator!=(const TimeZone& that) const; 90*0e209d39SAndroid Build Coastguard Worker 91*0e209d39SAndroid Build Coastguard Worker /** 92*0e209d39SAndroid Build Coastguard Worker * Adds the `TimeZoneRule` which represents time transitions. 93*0e209d39SAndroid Build Coastguard Worker * The `TimeZoneRule` must have start times, that is, the result 94*0e209d39SAndroid Build Coastguard Worker * of `isTransitionRule()` must be true. Otherwise, U_ILLEGAL_ARGUMENT_ERROR 95*0e209d39SAndroid Build Coastguard Worker * is set to the error code. 96*0e209d39SAndroid Build Coastguard Worker * The input `TimeZoneRule` is adopted by this `RuleBasedTimeZone`; 97*0e209d39SAndroid Build Coastguard Worker * the caller must not delete it. Should an error condition prevent 98*0e209d39SAndroid Build Coastguard Worker * the successful adoption of the rule, this function will delete it. 99*0e209d39SAndroid Build Coastguard Worker * 100*0e209d39SAndroid Build Coastguard Worker * After all rules are added, the caller must call `complete()` method to 101*0e209d39SAndroid Build Coastguard Worker * make this `RuleBasedTimeZone` ready to handle common time 102*0e209d39SAndroid Build Coastguard Worker * zone functions. 103*0e209d39SAndroid Build Coastguard Worker * @param rule The `TimeZoneRule`. 104*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 105*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 106*0e209d39SAndroid Build Coastguard Worker */ 107*0e209d39SAndroid Build Coastguard Worker void addTransitionRule(TimeZoneRule* rule, UErrorCode& status); 108*0e209d39SAndroid Build Coastguard Worker 109*0e209d39SAndroid Build Coastguard Worker /** 110*0e209d39SAndroid Build Coastguard Worker * Makes the <code>TimeZoneRule</code> ready to handle actual timezone 111*0e209d39SAndroid Build Coastguard Worker * calculation APIs. This method collects time zone rules specified 112*0e209d39SAndroid Build Coastguard Worker * by the caller via the constructor and addTransitionRule() and 113*0e209d39SAndroid Build Coastguard Worker * builds internal structure for making the object ready to support 114*0e209d39SAndroid Build Coastguard Worker * time zone APIs such as getOffset(), getNextTransition() and others. 115*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 116*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 117*0e209d39SAndroid Build Coastguard Worker */ 118*0e209d39SAndroid Build Coastguard Worker void complete(UErrorCode& status); 119*0e209d39SAndroid Build Coastguard Worker 120*0e209d39SAndroid Build Coastguard Worker /** 121*0e209d39SAndroid Build Coastguard Worker * Clones TimeZone objects polymorphically. Clients are responsible for deleting 122*0e209d39SAndroid Build Coastguard Worker * the TimeZone object cloned. 123*0e209d39SAndroid Build Coastguard Worker * 124*0e209d39SAndroid Build Coastguard Worker * @return A new copy of this TimeZone object. 125*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 126*0e209d39SAndroid Build Coastguard Worker */ 127*0e209d39SAndroid Build Coastguard Worker virtual RuleBasedTimeZone* clone() const override; 128*0e209d39SAndroid Build Coastguard Worker 129*0e209d39SAndroid Build Coastguard Worker /** 130*0e209d39SAndroid Build Coastguard Worker * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add 131*0e209d39SAndroid Build Coastguard Worker * to GMT to get local time in this time zone, taking daylight savings time into 132*0e209d39SAndroid Build Coastguard Worker * account) as of a particular reference date. The reference date is used to determine 133*0e209d39SAndroid Build Coastguard Worker * whether daylight savings time is in effect and needs to be figured into the offset 134*0e209d39SAndroid Build Coastguard Worker * that is returned (in other words, what is the adjusted GMT offset in this time zone 135*0e209d39SAndroid Build Coastguard Worker * at this particular date and time?). For the time zones produced by createTimeZone(), 136*0e209d39SAndroid Build Coastguard Worker * the reference data is specified according to the Gregorian calendar, and the date 137*0e209d39SAndroid Build Coastguard Worker * and time fields are local standard time. 138*0e209d39SAndroid Build Coastguard Worker * 139*0e209d39SAndroid Build Coastguard Worker * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 140*0e209d39SAndroid Build Coastguard Worker * which returns both the raw and the DST offset for a given time. This method 141*0e209d39SAndroid Build Coastguard Worker * is retained only for backward compatibility. 142*0e209d39SAndroid Build Coastguard Worker * 143*0e209d39SAndroid Build Coastguard Worker * @param era The reference date's era 144*0e209d39SAndroid Build Coastguard Worker * @param year The reference date's year 145*0e209d39SAndroid Build Coastguard Worker * @param month The reference date's month (0-based; 0 is January) 146*0e209d39SAndroid Build Coastguard Worker * @param day The reference date's day-in-month (1-based) 147*0e209d39SAndroid Build Coastguard Worker * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 148*0e209d39SAndroid Build Coastguard Worker * @param millis The reference date's milliseconds in day, local standard time 149*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 150*0e209d39SAndroid Build Coastguard Worker * @return The offset in milliseconds to add to GMT to get local time. 151*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 152*0e209d39SAndroid Build Coastguard Worker */ 153*0e209d39SAndroid Build Coastguard Worker virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 154*0e209d39SAndroid Build Coastguard Worker uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const override; 155*0e209d39SAndroid Build Coastguard Worker 156*0e209d39SAndroid Build Coastguard Worker /** 157*0e209d39SAndroid Build Coastguard Worker * Gets the time zone offset, for current date, modified in case of 158*0e209d39SAndroid Build Coastguard Worker * daylight savings. This is the offset to add *to* UTC to get local time. 159*0e209d39SAndroid Build Coastguard Worker * 160*0e209d39SAndroid Build Coastguard Worker * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 161*0e209d39SAndroid Build Coastguard Worker * which returns both the raw and the DST offset for a given time. This method 162*0e209d39SAndroid Build Coastguard Worker * is retained only for backward compatibility. 163*0e209d39SAndroid Build Coastguard Worker * 164*0e209d39SAndroid Build Coastguard Worker * @param era The reference date's era 165*0e209d39SAndroid Build Coastguard Worker * @param year The reference date's year 166*0e209d39SAndroid Build Coastguard Worker * @param month The reference date's month (0-based; 0 is January) 167*0e209d39SAndroid Build Coastguard Worker * @param day The reference date's day-in-month (1-based) 168*0e209d39SAndroid Build Coastguard Worker * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 169*0e209d39SAndroid Build Coastguard Worker * @param millis The reference date's milliseconds in day, local standard time 170*0e209d39SAndroid Build Coastguard Worker * @param monthLength The length of the given month in days. 171*0e209d39SAndroid Build Coastguard Worker * @param status Output param to filled in with a success or an error. 172*0e209d39SAndroid Build Coastguard Worker * @return The offset in milliseconds to add to GMT to get local time. 173*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 174*0e209d39SAndroid Build Coastguard Worker */ 175*0e209d39SAndroid Build Coastguard Worker virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 176*0e209d39SAndroid Build Coastguard Worker uint8_t dayOfWeek, int32_t millis, 177*0e209d39SAndroid Build Coastguard Worker int32_t monthLength, UErrorCode& status) const override; 178*0e209d39SAndroid Build Coastguard Worker 179*0e209d39SAndroid Build Coastguard Worker /** 180*0e209d39SAndroid Build Coastguard Worker * Returns the time zone raw and GMT offset for the given moment 181*0e209d39SAndroid Build Coastguard Worker * in time. Upon return, local-millis = GMT-millis + rawOffset + 182*0e209d39SAndroid Build Coastguard Worker * dstOffset. All computations are performed in the proleptic 183*0e209d39SAndroid Build Coastguard Worker * Gregorian calendar. The default implementation in the TimeZone 184*0e209d39SAndroid Build Coastguard Worker * class delegates to the 8-argument getOffset(). 185*0e209d39SAndroid Build Coastguard Worker * 186*0e209d39SAndroid Build Coastguard Worker * @param date moment in time for which to return offsets, in 187*0e209d39SAndroid Build Coastguard Worker * units of milliseconds from January 1, 1970 0:00 GMT, either GMT 188*0e209d39SAndroid Build Coastguard Worker * time or local wall time, depending on `local'. 189*0e209d39SAndroid Build Coastguard Worker * @param local if true, `date' is local wall time; otherwise it 190*0e209d39SAndroid Build Coastguard Worker * is in GMT time. 191*0e209d39SAndroid Build Coastguard Worker * @param rawOffset output parameter to receive the raw offset, that 192*0e209d39SAndroid Build Coastguard Worker * is, the offset not including DST adjustments 193*0e209d39SAndroid Build Coastguard Worker * @param dstOffset output parameter to receive the DST offset, 194*0e209d39SAndroid Build Coastguard Worker * that is, the offset to be added to `rawOffset' to obtain the 195*0e209d39SAndroid Build Coastguard Worker * total offset between local and GMT time. If DST is not in 196*0e209d39SAndroid Build Coastguard Worker * effect, this value is zero; otherwise it is a positive value, 197*0e209d39SAndroid Build Coastguard Worker * typically one hour. 198*0e209d39SAndroid Build Coastguard Worker * @param ec input-output error code 199*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 200*0e209d39SAndroid Build Coastguard Worker */ 201*0e209d39SAndroid Build Coastguard Worker virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 202*0e209d39SAndroid Build Coastguard Worker int32_t& dstOffset, UErrorCode& ec) const override; 203*0e209d39SAndroid Build Coastguard Worker 204*0e209d39SAndroid Build Coastguard Worker /** 205*0e209d39SAndroid Build Coastguard Worker * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 206*0e209d39SAndroid Build Coastguard Worker * to GMT to get local time, before taking daylight savings time into account). 207*0e209d39SAndroid Build Coastguard Worker * 208*0e209d39SAndroid Build Coastguard Worker * @param offsetMillis The new raw GMT offset for this time zone. 209*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 210*0e209d39SAndroid Build Coastguard Worker */ 211*0e209d39SAndroid Build Coastguard Worker virtual void setRawOffset(int32_t offsetMillis) override; 212*0e209d39SAndroid Build Coastguard Worker 213*0e209d39SAndroid Build Coastguard Worker /** 214*0e209d39SAndroid Build Coastguard Worker * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 215*0e209d39SAndroid Build Coastguard Worker * to GMT to get local time, before taking daylight savings time into account). 216*0e209d39SAndroid Build Coastguard Worker * 217*0e209d39SAndroid Build Coastguard Worker * @return The TimeZone's raw GMT offset. 218*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 219*0e209d39SAndroid Build Coastguard Worker */ 220*0e209d39SAndroid Build Coastguard Worker virtual int32_t getRawOffset() const override; 221*0e209d39SAndroid Build Coastguard Worker 222*0e209d39SAndroid Build Coastguard Worker /** 223*0e209d39SAndroid Build Coastguard Worker * Queries if this time zone uses daylight savings time. 224*0e209d39SAndroid Build Coastguard Worker * @return true if this time zone uses daylight savings time, 225*0e209d39SAndroid Build Coastguard Worker * false, otherwise. 226*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 227*0e209d39SAndroid Build Coastguard Worker */ 228*0e209d39SAndroid Build Coastguard Worker virtual UBool useDaylightTime() const override; 229*0e209d39SAndroid Build Coastguard Worker 230*0e209d39SAndroid Build Coastguard Worker #ifndef U_FORCE_HIDE_DEPRECATED_API 231*0e209d39SAndroid Build Coastguard Worker /** 232*0e209d39SAndroid Build Coastguard Worker * Queries if the given date is in daylight savings time in 233*0e209d39SAndroid Build Coastguard Worker * this time zone. 234*0e209d39SAndroid Build Coastguard Worker * This method is wasteful since it creates a new GregorianCalendar and 235*0e209d39SAndroid Build Coastguard Worker * deletes it each time it is called. This is a deprecated method 236*0e209d39SAndroid Build Coastguard Worker * and provided only for Java compatibility. 237*0e209d39SAndroid Build Coastguard Worker * 238*0e209d39SAndroid Build Coastguard Worker * @param date the given UDate. 239*0e209d39SAndroid Build Coastguard Worker * @param status Output param filled in with success/error code. 240*0e209d39SAndroid Build Coastguard Worker * @return true if the given date is in daylight savings time, 241*0e209d39SAndroid Build Coastguard Worker * false, otherwise. 242*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. 243*0e209d39SAndroid Build Coastguard Worker */ 244*0e209d39SAndroid Build Coastguard Worker virtual UBool inDaylightTime(UDate date, UErrorCode& status) const override; 245*0e209d39SAndroid Build Coastguard Worker #endif // U_FORCE_HIDE_DEPRECATED_API 246*0e209d39SAndroid Build Coastguard Worker 247*0e209d39SAndroid Build Coastguard Worker /** 248*0e209d39SAndroid Build Coastguard Worker * Returns true if this zone has the same rule and offset as another zone. 249*0e209d39SAndroid Build Coastguard Worker * That is, if this zone differs only in ID, if at all. 250*0e209d39SAndroid Build Coastguard Worker * @param other the <code>TimeZone</code> object to be compared with 251*0e209d39SAndroid Build Coastguard Worker * @return true if the given zone is the same as this one, 252*0e209d39SAndroid Build Coastguard Worker * with the possible exception of the ID 253*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 254*0e209d39SAndroid Build Coastguard Worker */ 255*0e209d39SAndroid Build Coastguard Worker virtual UBool hasSameRules(const TimeZone& other) const override; 256*0e209d39SAndroid Build Coastguard Worker 257*0e209d39SAndroid Build Coastguard Worker /** 258*0e209d39SAndroid Build Coastguard Worker * Gets the first time zone transition after the base time. 259*0e209d39SAndroid Build Coastguard Worker * @param base The base time. 260*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 261*0e209d39SAndroid Build Coastguard Worker * @param result Receives the first transition after the base time. 262*0e209d39SAndroid Build Coastguard Worker * @return true if the transition is found. 263*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 264*0e209d39SAndroid Build Coastguard Worker */ 265*0e209d39SAndroid Build Coastguard Worker virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 266*0e209d39SAndroid Build Coastguard Worker 267*0e209d39SAndroid Build Coastguard Worker /** 268*0e209d39SAndroid Build Coastguard Worker * Gets the most recent time zone transition before the base time. 269*0e209d39SAndroid Build Coastguard Worker * @param base The base time. 270*0e209d39SAndroid Build Coastguard Worker * @param inclusive Whether the base time is inclusive or not. 271*0e209d39SAndroid Build Coastguard Worker * @param result Receives the most recent transition before the base time. 272*0e209d39SAndroid Build Coastguard Worker * @return true if the transition is found. 273*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 274*0e209d39SAndroid Build Coastguard Worker */ 275*0e209d39SAndroid Build Coastguard Worker virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 276*0e209d39SAndroid Build Coastguard Worker 277*0e209d39SAndroid Build Coastguard Worker /** 278*0e209d39SAndroid Build Coastguard Worker * Returns the number of <code>TimeZoneRule</code>s which represents time transitions, 279*0e209d39SAndroid Build Coastguard Worker * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except 280*0e209d39SAndroid Build Coastguard Worker * <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value. 281*0e209d39SAndroid Build Coastguard Worker * @param status Receives error status code. 282*0e209d39SAndroid Build Coastguard Worker * @return The number of <code>TimeZoneRule</code>s representing time transitions. 283*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 284*0e209d39SAndroid Build Coastguard Worker */ 285*0e209d39SAndroid Build Coastguard Worker virtual int32_t countTransitionRules(UErrorCode& status) const override; 286*0e209d39SAndroid Build Coastguard Worker 287*0e209d39SAndroid Build Coastguard Worker /** 288*0e209d39SAndroid Build Coastguard Worker * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code> 289*0e209d39SAndroid Build Coastguard Worker * which represent time transitions for this time zone. On successful return, 290*0e209d39SAndroid Build Coastguard Worker * the argument initial points to non-nullptr <code>InitialTimeZoneRule</code> and 291*0e209d39SAndroid Build Coastguard Worker * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code> 292*0e209d39SAndroid Build Coastguard Worker * instances up to the size specified by trscount. The results are referencing the 293*0e209d39SAndroid Build Coastguard Worker * rule instance held by this time zone instance. Therefore, after this time zone 294*0e209d39SAndroid Build Coastguard Worker * is destructed, they are no longer available. 295*0e209d39SAndroid Build Coastguard Worker * @param initial Receives the initial timezone rule 296*0e209d39SAndroid Build Coastguard Worker * @param trsrules Receives the timezone transition rules 297*0e209d39SAndroid Build Coastguard Worker * @param trscount On input, specify the size of the array 'transitions' receiving 298*0e209d39SAndroid Build Coastguard Worker * the timezone transition rules. On output, actual number of 299*0e209d39SAndroid Build Coastguard Worker * rules filled in the array will be set. 300*0e209d39SAndroid Build Coastguard Worker * @param status Receives error status code. 301*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 302*0e209d39SAndroid Build Coastguard Worker */ 303*0e209d39SAndroid Build Coastguard Worker virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, 304*0e209d39SAndroid Build Coastguard Worker const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const override; 305*0e209d39SAndroid Build Coastguard Worker 306*0e209d39SAndroid Build Coastguard Worker /** 307*0e209d39SAndroid Build Coastguard Worker * Get time zone offsets from local wall time. 308*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 309*0e209d39SAndroid Build Coastguard Worker */ 310*0e209d39SAndroid Build Coastguard Worker virtual void getOffsetFromLocal( 311*0e209d39SAndroid Build Coastguard Worker UDate date, UTimeZoneLocalOption nonExistingTimeOpt, 312*0e209d39SAndroid Build Coastguard Worker UTimeZoneLocalOption duplicatedTimeOpt, 313*0e209d39SAndroid Build Coastguard Worker int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const override; 314*0e209d39SAndroid Build Coastguard Worker 315*0e209d39SAndroid Build Coastguard Worker private: 316*0e209d39SAndroid Build Coastguard Worker void deleteRules(); 317*0e209d39SAndroid Build Coastguard Worker void deleteTransitions(); 318*0e209d39SAndroid Build Coastguard Worker UVector* copyRules(UVector* source); 319*0e209d39SAndroid Build Coastguard Worker TimeZoneRule* findRuleInFinal(UDate date, UBool local, 320*0e209d39SAndroid Build Coastguard Worker int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const; 321*0e209d39SAndroid Build Coastguard Worker UBool findNext(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const; 322*0e209d39SAndroid Build Coastguard Worker UBool findPrev(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const; 323*0e209d39SAndroid Build Coastguard Worker int32_t getLocalDelta(int32_t rawBefore, int32_t dstBefore, int32_t rawAfter, int32_t dstAfter, 324*0e209d39SAndroid Build Coastguard Worker int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const; 325*0e209d39SAndroid Build Coastguard Worker UDate getTransitionTime(Transition* transition, UBool local, 326*0e209d39SAndroid Build Coastguard Worker int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const; 327*0e209d39SAndroid Build Coastguard Worker void getOffsetInternal(UDate date, UBool local, int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt, 328*0e209d39SAndroid Build Coastguard Worker int32_t& rawOffset, int32_t& dstOffset, UErrorCode& ec) const; 329*0e209d39SAndroid Build Coastguard Worker void completeConst(UErrorCode &status) const; 330*0e209d39SAndroid Build Coastguard Worker 331*0e209d39SAndroid Build Coastguard Worker InitialTimeZoneRule *fInitialRule; 332*0e209d39SAndroid Build Coastguard Worker UVector *fHistoricRules; 333*0e209d39SAndroid Build Coastguard Worker UVector *fFinalRules; 334*0e209d39SAndroid Build Coastguard Worker UVector *fHistoricTransitions; 335*0e209d39SAndroid Build Coastguard Worker UBool fUpToDate; 336*0e209d39SAndroid Build Coastguard Worker 337*0e209d39SAndroid Build Coastguard Worker public: 338*0e209d39SAndroid Build Coastguard Worker /** 339*0e209d39SAndroid Build Coastguard Worker * Return the class ID for this class. This is useful only for comparing to 340*0e209d39SAndroid Build Coastguard Worker * a return value from getDynamicClassID(). For example: 341*0e209d39SAndroid Build Coastguard Worker * <pre> 342*0e209d39SAndroid Build Coastguard Worker * . Base* polymorphic_pointer = createPolymorphicObject(); 343*0e209d39SAndroid Build Coastguard Worker * . if (polymorphic_pointer->getDynamicClassID() == 344*0e209d39SAndroid Build Coastguard Worker * . erived::getStaticClassID()) ... 345*0e209d39SAndroid Build Coastguard Worker * </pre> 346*0e209d39SAndroid Build Coastguard Worker * @return The class ID for all objects of this class. 347*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 348*0e209d39SAndroid Build Coastguard Worker */ 349*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 350*0e209d39SAndroid Build Coastguard Worker 351*0e209d39SAndroid Build Coastguard Worker /** 352*0e209d39SAndroid Build Coastguard Worker * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 353*0e209d39SAndroid Build Coastguard Worker * method is to implement a simple version of RTTI, since not all C++ 354*0e209d39SAndroid Build Coastguard Worker * compilers support genuine RTTI. Polymorphic operator==() and clone() 355*0e209d39SAndroid Build Coastguard Worker * methods call this method. 356*0e209d39SAndroid Build Coastguard Worker * 357*0e209d39SAndroid Build Coastguard Worker * @return The class ID for this object. All objects of a 358*0e209d39SAndroid Build Coastguard Worker * given class have the same class ID. Objects of 359*0e209d39SAndroid Build Coastguard Worker * other classes have different class IDs. 360*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 361*0e209d39SAndroid Build Coastguard Worker */ 362*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 363*0e209d39SAndroid Build Coastguard Worker }; 364*0e209d39SAndroid Build Coastguard Worker 365*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 366*0e209d39SAndroid Build Coastguard Worker 367*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 368*0e209d39SAndroid Build Coastguard Worker 369*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */ 370*0e209d39SAndroid Build Coastguard Worker 371*0e209d39SAndroid Build Coastguard Worker #endif // RBTZ_H 372*0e209d39SAndroid Build Coastguard Worker 373*0e209d39SAndroid Build Coastguard Worker //eof 374