RuleBasedTimeZone
InitialTimeZoneRule
TimeZone
TimeZoneRule
Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 140 * which returns both the raw and the DST offset for a given time. This method 141 * is retained only for backward compatibility. 142 * 143 * @param era The reference date's era 144 * @param year The reference date's year 145 * @param month The reference date's month (0-based; 0 is January) 146 * @param day The reference date's day-in-month (1-based) 147 * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 148 * @param millis The reference date's milliseconds in day, local standard time 149 * @param status Output param to filled in with a success or an error. 150 * @return The offset in milliseconds to add to GMT to get local time. 151 * @stable ICU 3.8 152 */ 153 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 154 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const override; 155 156 /** 157 * Gets the time zone offset, for current date, modified in case of 158 * daylight savings. This is the offset to add *to* UTC to get local time. 159 * 160 *
Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 161 * which returns both the raw and the DST offset for a given time. This method 162 * is retained only for backward compatibility. 163 * 164 * @param era The reference date's era 165 * @param year The reference date's year 166 * @param month The reference date's month (0-based; 0 is January) 167 * @param day The reference date's day-in-month (1-based) 168 * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 169 * @param millis The reference date's milliseconds in day, local standard time 170 * @param monthLength The length of the given month in days. 171 * @param status Output param to filled in with a success or an error. 172 * @return The offset in milliseconds to add to GMT to get local time. 173 * @stable ICU 3.8 174 */ 175 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 176 uint8_t dayOfWeek, int32_t millis, 177 int32_t monthLength, UErrorCode& status) const override; 178 179 /** 180 * Returns the time zone raw and GMT offset for the given moment 181 * in time. Upon return, local-millis = GMT-millis + rawOffset + 182 * dstOffset. All computations are performed in the proleptic 183 * Gregorian calendar. The default implementation in the TimeZone 184 * class delegates to the 8-argument getOffset(). 185 * 186 * @param date moment in time for which to return offsets, in 187 * units of milliseconds from January 1, 1970 0:00 GMT, either GMT 188 * time or local wall time, depending on `local'. 189 * @param local if true, `date' is local wall time; otherwise it 190 * is in GMT time. 191 * @param rawOffset output parameter to receive the raw offset, that 192 * is, the offset not including DST adjustments 193 * @param dstOffset output parameter to receive the DST offset, 194 * that is, the offset to be added to `rawOffset' to obtain the 195 * total offset between local and GMT time. If DST is not in 196 * effect, this value is zero; otherwise it is a positive value, 197 * typically one hour. 198 * @param ec input-output error code 199 * @stable ICU 3.8 200 */ 201 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 202 int32_t& dstOffset, UErrorCode& ec) const override; 203 204 /** 205 * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 206 * to GMT to get local time, before taking daylight savings time into account). 207 * 208 * @param offsetMillis The new raw GMT offset for this time zone. 209 * @stable ICU 3.8 210 */ 211 virtual void setRawOffset(int32_t offsetMillis) override; 212 213 /** 214 * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 215 * to GMT to get local time, before taking daylight savings time into account). 216 * 217 * @return The TimeZone's raw GMT offset. 218 * @stable ICU 3.8 219 */ 220 virtual int32_t getRawOffset(void) const override; 221 222 /** 223 * Queries if this time zone uses daylight savings time. 224 * @return true if this time zone uses daylight savings time, 225 * false, otherwise. 226 * @stable ICU 3.8 227 */ 228 virtual UBool useDaylightTime(void) const override; 229 230 #ifndef U_FORCE_HIDE_DEPRECATED_API 231 /** 232 * Queries if the given date is in daylight savings time in 233 * this time zone. 234 * This method is wasteful since it creates a new GregorianCalendar and 235 * deletes it each time it is called. This is a deprecated method 236 * and provided only for Java compatibility. 237 * 238 * @param date the given UDate. 239 * @param status Output param filled in with success/error code. 240 * @return true if the given date is in daylight savings time, 241 * false, otherwise. 242 * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. 243 */ 244 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const override; 245 #endif // U_FORCE_HIDE_DEPRECATED_API 246 247 /** 248 * Returns true if this zone has the same rule and offset as another zone. 249 * That is, if this zone differs only in ID, if at all. 250 * @param other the TimeZone object to be compared with 251 * @return true if the given zone is the same as this one, 252 * with the possible exception of the ID 253 * @stable ICU 3.8 254 */ 255 virtual UBool hasSameRules(const TimeZone& other) const override; 256 257 /** 258 * Gets the first time zone transition after the base time. 259 * @param base The base time. 260 * @param inclusive Whether the base time is inclusive or not. 261 * @param result Receives the first transition after the base time. 262 * @return true if the transition is found. 263 * @stable ICU 3.8 264 */ 265 virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 266 267 /** 268 * Gets the most recent time zone transition before the base time. 269 * @param base The base time. 270 * @param inclusive Whether the base time is inclusive or not. 271 * @param result Receives the most recent transition before the base time. 272 * @return true if the transition is found. 273 * @stable ICU 3.8 274 */ 275 virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 276 277 /** 278 * Returns the number of TimeZoneRules which represents time transitions, 279 * for this time zone, that is, all TimeZoneRules for this time zone except 280 * InitialTimeZoneRule. The return value range is 0 or any positive value. 281 * @param status Receives error status code. 282 * @return The number of TimeZoneRules representing time transitions. 283 * @stable ICU 3.8 284 */ 285 virtual int32_t countTransitionRules(UErrorCode& status) const override; 286 287 /** 288 * Gets the InitialTimeZoneRule and the set of TimeZoneRule 289 * which represent time transitions for this time zone. On successful return, 290 * the argument initial points to non-nullptr InitialTimeZoneRule and 291 * the array trsrules is filled with 0 or multiple TimeZoneRule 292 * instances up to the size specified by trscount. The results are referencing the 293 * rule instance held by this time zone instance. Therefore, after this time zone 294 * is destructed, they are no longer available. 295 * @param initial Receives the initial timezone rule 296 * @param trsrules Receives the timezone transition rules 297 * @param trscount On input, specify the size of the array 'transitions' receiving 298 * the timezone transition rules. On output, actual number of 299 * rules filled in the array will be set. 300 * @param status Receives error status code. 301 * @stable ICU 3.8 302 */ 303 virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, 304 const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const override; 305 306 /** 307 * Get time zone offsets from local wall time. 308 * @stable ICU 69 309 */ 310 virtual void getOffsetFromLocal( 311 UDate date, UTimeZoneLocalOption nonExistingTimeOpt, 312 UTimeZoneLocalOption duplicatedTimeOpt, 313 int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const override; 314 315 private: 316 void deleteRules(void); 317 void deleteTransitions(void); 318 UVector* copyRules(UVector* source); 319 TimeZoneRule* findRuleInFinal(UDate date, UBool local, 320 int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const; 321 UBool findNext(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const; 322 UBool findPrev(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const; 323 int32_t getLocalDelta(int32_t rawBefore, int32_t dstBefore, int32_t rawAfter, int32_t dstAfter, 324 int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const; 325 UDate getTransitionTime(Transition* transition, UBool local, 326 int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const; 327 void getOffsetInternal(UDate date, UBool local, int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt, 328 int32_t& rawOffset, int32_t& dstOffset, UErrorCode& ec) const; 329 void completeConst(UErrorCode &status) const; 330 331 InitialTimeZoneRule *fInitialRule; 332 UVector *fHistoricRules; 333 UVector *fFinalRules; 334 UVector *fHistoricTransitions; 335 UBool fUpToDate; 336 337 public: 338 /** 339 * Return the class ID for this class. This is useful only for comparing to 340 * a return value from getDynamicClassID(). For example: 341 *
342 * . Base* polymorphic_pointer = createPolymorphicObject(); 343 * . if (polymorphic_pointer->getDynamicClassID() == 344 * . erived::getStaticClassID()) ... 345 *