VTimeZone
TimeZone
BasicTimeZone
Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 203 * which returns both the raw and the DST offset for a given time. This method 204 * is retained only for backward compatibility. 205 * 206 * @param era The reference date's era 207 * @param year The reference date's year 208 * @param month The reference date's month (0-based; 0 is January) 209 * @param day The reference date's day-in-month (1-based) 210 * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 211 * @param millis The reference date's milliseconds in day, local standard time 212 * @param status Output param to filled in with a success or an error. 213 * @return The offset in milliseconds to add to GMT to get local time. 214 * @stable ICU 3.8 215 */ 216 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 217 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const override; 218 219 /** 220 * Gets the time zone offset, for current date, modified in case of 221 * daylight savings. This is the offset to add *to* UTC to get local time. 222 * 223 *
Note: Don't call this method. Instead, call the getOffset(UDate...) overload, 224 * which returns both the raw and the DST offset for a given time. This method 225 * is retained only for backward compatibility. 226 * 227 * @param era The reference date's era 228 * @param year The reference date's year 229 * @param month The reference date's month (0-based; 0 is January) 230 * @param day The reference date's day-in-month (1-based) 231 * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) 232 * @param millis The reference date's milliseconds in day, local standard time 233 * @param monthLength The length of the given month in days. 234 * @param status Output param to filled in with a success or an error. 235 * @return The offset in milliseconds to add to GMT to get local time. 236 * @stable ICU 3.8 237 */ 238 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 239 uint8_t dayOfWeek, int32_t millis, 240 int32_t monthLength, UErrorCode& status) const override; 241 242 /** 243 * Returns the time zone raw and GMT offset for the given moment 244 * in time. Upon return, local-millis = GMT-millis + rawOffset + 245 * dstOffset. All computations are performed in the proleptic 246 * Gregorian calendar. The default implementation in the TimeZone 247 * class delegates to the 8-argument getOffset(). 248 * 249 * @param date moment in time for which to return offsets, in 250 * units of milliseconds from January 1, 1970 0:00 GMT, either GMT 251 * time or local wall time, depending on `local'. 252 * @param local if true, `date' is local wall time; otherwise it 253 * is in GMT time. 254 * @param rawOffset output parameter to receive the raw offset, that 255 * is, the offset not including DST adjustments 256 * @param dstOffset output parameter to receive the DST offset, 257 * that is, the offset to be added to `rawOffset' to obtain the 258 * total offset between local and GMT time. If DST is not in 259 * effect, this value is zero; otherwise it is a positive value, 260 * typically one hour. 261 * @param ec input-output error code 262 * @stable ICU 3.8 263 */ 264 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 265 int32_t& dstOffset, UErrorCode& ec) const override; 266 267 /** 268 * Get time zone offsets from local wall time. 269 * @stable ICU 69 270 */ 271 virtual void getOffsetFromLocal( 272 UDate date, UTimeZoneLocalOption nonExistingTimeOpt, 273 UTimeZoneLocalOption duplicatedTimeOpt, 274 int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const override; 275 276 /** 277 * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 278 * to GMT to get local time, before taking daylight savings time into account). 279 * 280 * @param offsetMillis The new raw GMT offset for this time zone. 281 * @stable ICU 3.8 282 */ 283 virtual void setRawOffset(int32_t offsetMillis) override; 284 285 /** 286 * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add 287 * to GMT to get local time, before taking daylight savings time into account). 288 * 289 * @return The TimeZone's raw GMT offset. 290 * @stable ICU 3.8 291 */ 292 virtual int32_t getRawOffset(void) const override; 293 294 /** 295 * Queries if this time zone uses daylight savings time. 296 * @return true if this time zone uses daylight savings time, 297 * false, otherwise. 298 * @stable ICU 3.8 299 */ 300 virtual UBool useDaylightTime(void) const override; 301 302 #ifndef U_FORCE_HIDE_DEPRECATED_API 303 /** 304 * Queries if the given date is in daylight savings time in 305 * this time zone. 306 * This method is wasteful since it creates a new GregorianCalendar and 307 * deletes it each time it is called. This is a deprecated method 308 * and provided only for Java compatibility. 309 * 310 * @param date the given UDate. 311 * @param status Output param filled in with success/error code. 312 * @return true if the given date is in daylight savings time, 313 * false, otherwise. 314 * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. 315 */ 316 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const override; 317 #endif // U_FORCE_HIDE_DEPRECATED_API 318 319 /** 320 * Returns true if this zone has the same rule and offset as another zone. 321 * That is, if this zone differs only in ID, if at all. 322 * @param other the TimeZone object to be compared with 323 * @return true if the given zone is the same as this one, 324 * with the possible exception of the ID 325 * @stable ICU 3.8 326 */ 327 virtual UBool hasSameRules(const TimeZone& other) const override; 328 329 /** 330 * Gets the first time zone transition after the base time. 331 * @param base The base time. 332 * @param inclusive Whether the base time is inclusive or not. 333 * @param result Receives the first transition after the base time. 334 * @return true if the transition is found. 335 * @stable ICU 3.8 336 */ 337 virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 338 339 /** 340 * Gets the most recent time zone transition before the base time. 341 * @param base The base time. 342 * @param inclusive Whether the base time is inclusive or not. 343 * @param result Receives the most recent transition before the base time. 344 * @return true if the transition is found. 345 * @stable ICU 3.8 346 */ 347 virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 348 349 /** 350 * Returns the number of TimeZoneRules which represents time transitions, 351 * for this time zone, that is, all TimeZoneRules for this time zone except 352 * InitialTimeZoneRule. The return value range is 0 or any positive value. 353 * @param status Receives error status code. 354 * @return The number of TimeZoneRules representing time transitions. 355 * @stable ICU 3.8 356 */ 357 virtual int32_t countTransitionRules(UErrorCode& status) const override; 358 359 /** 360 * Gets the InitialTimeZoneRule and the set of TimeZoneRule 361 * which represent time transitions for this time zone. On successful return, 362 * the argument initial points to non-nullptr InitialTimeZoneRule and 363 * the array trsrules is filled with 0 or multiple TimeZoneRule 364 * instances up to the size specified by trscount. The results are referencing the 365 * rule instance held by this time zone instance. Therefore, after this time zone 366 * is destructed, they are no longer available. 367 * @param initial Receives the initial timezone rule 368 * @param trsrules Receives the timezone transition rules 369 * @param trscount On input, specify the size of the array 'transitions' receiving 370 * the timezone transition rules. On output, actual number of 371 * rules filled in the array will be set. 372 * @param status Receives error status code. 373 * @stable ICU 3.8 374 */ 375 virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, 376 const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const override; 377 378 private: 379 enum { DEFAULT_VTIMEZONE_LINES = 100 }; 380 381 /** 382 * Default constructor. 383 */ 384 VTimeZone(); 385 void write(VTZWriter& writer, UErrorCode& status) const; 386 void write(UDate start, VTZWriter& writer, UErrorCode& status) const; 387 void writeSimple(UDate time, VTZWriter& writer, UErrorCode& status) const; 388 void load(VTZReader& reader, UErrorCode& status); 389 void parse(UErrorCode& status); 390 391 void writeZone(VTZWriter& w, BasicTimeZone& basictz, UVector* customProps, 392 UErrorCode& status) const; 393 394 void writeHeaders(VTZWriter& w, UErrorCode& status) const; 395 void writeFooter(VTZWriter& writer, UErrorCode& status) const; 396 397 void writeZonePropsByTime(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 398 int32_t fromOffset, int32_t toOffset, UDate time, UBool withRDATE, 399 UErrorCode& status) const; 400 void writeZonePropsByDOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 401 int32_t fromOffset, int32_t toOffset, 402 int32_t month, int32_t dayOfMonth, UDate startTime, UDate untilTime, 403 UErrorCode& status) const; 404 void writeZonePropsByDOW(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 405 int32_t fromOffset, int32_t toOffset, 406 int32_t month, int32_t weekInMonth, int32_t dayOfWeek, 407 UDate startTime, UDate untilTime, UErrorCode& status) const; 408 void writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 409 int32_t fromOffset, int32_t toOffset, 410 int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 411 UDate startTime, UDate untilTime, UErrorCode& status) const; 412 void writeZonePropsByDOW_GEQ_DOM_sub(VTZWriter& writer, int32_t month, int32_t dayOfMonth, 413 int32_t dayOfWeek, int32_t numDays, 414 UDate untilTime, int32_t fromOffset, UErrorCode& status) const; 415 void writeZonePropsByDOW_LEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 416 int32_t fromOffset, int32_t toOffset, 417 int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 418 UDate startTime, UDate untilTime, UErrorCode& status) const; 419 void writeFinalRule(VTZWriter& writer, UBool isDst, const AnnualTimeZoneRule* rule, 420 int32_t fromRawOffset, int32_t fromDSTSavings, 421 UDate startTime, UErrorCode& status) const; 422 423 void beginZoneProps(VTZWriter& writer, UBool isDst, const UnicodeString& zonename, 424 int32_t fromOffset, int32_t toOffset, UDate startTime, UErrorCode& status) const; 425 void endZoneProps(VTZWriter& writer, UBool isDst, UErrorCode& status) const; 426 void beginRRULE(VTZWriter& writer, int32_t month, UErrorCode& status) const; 427 void appendUNTIL(VTZWriter& writer, const UnicodeString& until, UErrorCode& status) const; 428 429 BasicTimeZone *tz; 430 UVector *vtzlines; 431 UnicodeString tzurl; 432 UDate lastmod; 433 UnicodeString olsonzid; 434 UnicodeString icutzver; 435 436 public: 437 /** 438 * Return the class ID for this class. This is useful only for comparing to 439 * a return value from getDynamicClassID(). For example: 440 *
TimeZoneRule
InitialTimeZoneRule
441 * . Base* polymorphic_pointer = createPolymorphicObject(); 442 * . if (polymorphic_pointer->getDynamicClassID() == 443 * . erived::getStaticClassID()) ... 444 *