|
||||
File indexing completed on 2025-01-18 10:13:09
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ******************************************************************************* 0005 * Copyright (C) 2007-2008, International Business Machines Corporation and * 0006 * others. All Rights Reserved. * 0007 ******************************************************************************* 0008 */ 0009 #ifndef TZRULE_H 0010 #define TZRULE_H 0011 0012 /** 0013 * \file 0014 * \brief C++ API: Time zone rule classes 0015 */ 0016 0017 #include "unicode/utypes.h" 0018 0019 #if U_SHOW_CPLUSPLUS_API 0020 0021 #if !UCONFIG_NO_FORMATTING 0022 0023 #include "unicode/uobject.h" 0024 #include "unicode/unistr.h" 0025 #include "unicode/dtrule.h" 0026 0027 U_NAMESPACE_BEGIN 0028 0029 /** 0030 * <code>TimeZoneRule</code> is a class representing a rule for time zone. 0031 * <code>TimeZoneRule</code> has a set of time zone attributes, such as zone name, 0032 * raw offset (UTC offset for standard time) and daylight saving time offset. 0033 * 0034 * @stable ICU 3.8 0035 */ 0036 class U_I18N_API TimeZoneRule : public UObject { 0037 public: 0038 /** 0039 * Destructor. 0040 * @stable ICU 3.8 0041 */ 0042 virtual ~TimeZoneRule(); 0043 0044 /** 0045 * Clone this TimeZoneRule object polymorphically. The caller owns the result and 0046 * should delete it when done. 0047 * @return A copy of the object. 0048 * @stable ICU 3.8 0049 */ 0050 virtual TimeZoneRule* clone() const = 0; 0051 0052 /** 0053 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 0054 * of different subclasses are considered unequal. 0055 * @param that The object to be compared with. 0056 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 0057 * @stable ICU 3.8 0058 */ 0059 virtual bool operator==(const TimeZoneRule& that) const; 0060 0061 /** 0062 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 0063 * of different subclasses are considered unequal. 0064 * @param that The object to be compared with. 0065 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 0066 * @stable ICU 3.8 0067 */ 0068 virtual bool operator!=(const TimeZoneRule& that) const; 0069 0070 /** 0071 * Fills in "name" with the name of this time zone. 0072 * @param name Receives the name of this time zone. 0073 * @return A reference to "name" 0074 * @stable ICU 3.8 0075 */ 0076 UnicodeString& getName(UnicodeString& name) const; 0077 0078 /** 0079 * Gets the standard time offset. 0080 * @return The standard time offset from UTC in milliseconds. 0081 * @stable ICU 3.8 0082 */ 0083 int32_t getRawOffset(void) const; 0084 0085 /** 0086 * Gets the amount of daylight saving delta time from the standard time. 0087 * @return The amount of daylight saving offset used by this rule 0088 * in milliseconds. 0089 * @stable ICU 3.8 0090 */ 0091 int32_t getDSTSavings(void) const; 0092 0093 /** 0094 * Returns if this rule represents the same rule and offsets as another. 0095 * When two <code>TimeZoneRule</code> objects differ only its names, this method 0096 * returns true. 0097 * @param other The <code>TimeZoneRule</code> object to be compared with. 0098 * @return true if the other <code>TimeZoneRule</code> is the same as this one. 0099 * @stable ICU 3.8 0100 */ 0101 virtual UBool isEquivalentTo(const TimeZoneRule& other) const; 0102 0103 /** 0104 * Gets the very first time when this rule takes effect. 0105 * @param prevRawOffset The standard time offset from UTC before this rule 0106 * takes effect in milliseconds. 0107 * @param prevDSTSavings The amount of daylight saving offset from the 0108 * standard time. 0109 * @param result Receives the very first time when this rule takes effect. 0110 * @return true if the start time is available. When false is returned, output parameter 0111 * "result" is unchanged. 0112 * @stable ICU 3.8 0113 */ 0114 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0; 0115 0116 /** 0117 * Gets the final time when this rule takes effect. 0118 * @param prevRawOffset The standard time offset from UTC before this rule 0119 * takes effect in milliseconds. 0120 * @param prevDSTSavings The amount of daylight saving offset from the 0121 * standard time. 0122 * @param result Receives the final time when this rule takes effect. 0123 * @return true if the start time is available. When false is returned, output parameter 0124 * "result" is unchanged. 0125 * @stable ICU 3.8 0126 */ 0127 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0; 0128 0129 /** 0130 * Gets the first time when this rule takes effect after the specified time. 0131 * @param base The first start time after this base time will be returned. 0132 * @param prevRawOffset The standard time offset from UTC before this rule 0133 * takes effect in milliseconds. 0134 * @param prevDSTSavings The amount of daylight saving offset from the 0135 * standard time. 0136 * @param inclusive Whether the base time is inclusive or not. 0137 * @param result Receives The first time when this rule takes effect after 0138 * the specified base time. 0139 * @return true if the start time is available. When false is returned, output parameter 0140 * "result" is unchanged. 0141 * @stable ICU 3.8 0142 */ 0143 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0144 UBool inclusive, UDate& result) const = 0; 0145 0146 /** 0147 * Gets the most recent time when this rule takes effect before the specified time. 0148 * @param base The most recent time before this base time will be returned. 0149 * @param prevRawOffset The standard time offset from UTC before this rule 0150 * takes effect in milliseconds. 0151 * @param prevDSTSavings The amount of daylight saving offset from the 0152 * standard time. 0153 * @param inclusive Whether the base time is inclusive or not. 0154 * @param result Receives The most recent time when this rule takes effect before 0155 * the specified base time. 0156 * @return true if the start time is available. When false is returned, output parameter 0157 * "result" is unchanged. 0158 * @stable ICU 3.8 0159 */ 0160 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0161 UBool inclusive, UDate& result) const = 0; 0162 0163 protected: 0164 0165 /** 0166 * Constructs a <code>TimeZoneRule</code> with the name, the GMT offset of its 0167 * standard time and the amount of daylight saving offset adjustment. 0168 * @param name The time zone name. 0169 * @param rawOffset The UTC offset of its standard time in milliseconds. 0170 * @param dstSavings The amount of daylight saving offset adjustment in milliseconds. 0171 * If this ia a rule for standard time, the value of this argument is 0. 0172 * @stable ICU 3.8 0173 */ 0174 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings); 0175 0176 /** 0177 * Copy constructor. 0178 * @param source The TimeZoneRule object to be copied. 0179 * @stable ICU 3.8 0180 */ 0181 TimeZoneRule(const TimeZoneRule& source); 0182 0183 /** 0184 * Assignment operator. 0185 * @param right The object to be copied. 0186 * @stable ICU 3.8 0187 */ 0188 TimeZoneRule& operator=(const TimeZoneRule& right); 0189 0190 private: 0191 UnicodeString fName; // time name 0192 int32_t fRawOffset; // UTC offset of the standard time in milliseconds 0193 int32_t fDSTSavings; // DST saving amount in milliseconds 0194 }; 0195 0196 /** 0197 * <code>InitialTimeZoneRule</code> represents a time zone rule 0198 * representing a time zone effective from the beginning and 0199 * has no actual start times. 0200 * @stable ICU 3.8 0201 */ 0202 class U_I18N_API InitialTimeZoneRule : public TimeZoneRule { 0203 public: 0204 /** 0205 * Constructs an <code>InitialTimeZoneRule</code> with the name, the GMT offset of its 0206 * standard time and the amount of daylight saving offset adjustment. 0207 * @param name The time zone name. 0208 * @param rawOffset The UTC offset of its standard time in milliseconds. 0209 * @param dstSavings The amount of daylight saving offset adjustment in milliseconds. 0210 * If this ia a rule for standard time, the value of this argument is 0. 0211 * @stable ICU 3.8 0212 */ 0213 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings); 0214 0215 /** 0216 * Copy constructor. 0217 * @param source The InitialTimeZoneRule object to be copied. 0218 * @stable ICU 3.8 0219 */ 0220 InitialTimeZoneRule(const InitialTimeZoneRule& source); 0221 0222 /** 0223 * Destructor. 0224 * @stable ICU 3.8 0225 */ 0226 virtual ~InitialTimeZoneRule(); 0227 0228 /** 0229 * Clone this InitialTimeZoneRule object polymorphically. The caller owns the result and 0230 * should delete it when done. 0231 * @return A copy of the object. 0232 * @stable ICU 3.8 0233 */ 0234 virtual InitialTimeZoneRule* clone() const override; 0235 0236 /** 0237 * Assignment operator. 0238 * @param right The object to be copied. 0239 * @stable ICU 3.8 0240 */ 0241 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right); 0242 0243 /** 0244 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 0245 * of different subclasses are considered unequal. 0246 * @param that The object to be compared with. 0247 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 0248 * @stable ICU 3.8 0249 */ 0250 virtual bool operator==(const TimeZoneRule& that) const override; 0251 0252 /** 0253 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 0254 * of different subclasses are considered unequal. 0255 * @param that The object to be compared with. 0256 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 0257 * @stable ICU 3.8 0258 */ 0259 virtual bool operator!=(const TimeZoneRule& that) const override; 0260 0261 /** 0262 * Returns if this rule represents the same rule and offsets as another. 0263 * When two <code>TimeZoneRule</code> objects differ only its names, this method 0264 * returns true. 0265 * @param that The <code>TimeZoneRule</code> object to be compared with. 0266 * @return true if the other <code>TimeZoneRule</code> is equivalent to this one. 0267 * @stable ICU 3.8 0268 */ 0269 virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 0270 0271 /** 0272 * Gets the very first time when this rule takes effect. 0273 * @param prevRawOffset The standard time offset from UTC before this rule 0274 * takes effect in milliseconds. 0275 * @param prevDSTSavings The amount of daylight saving offset from the 0276 * standard time. 0277 * @param result Receives the very first time when this rule takes effect. 0278 * @return true if the start time is available. When false is returned, output parameter 0279 * "result" is unchanged. 0280 * @stable ICU 3.8 0281 */ 0282 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 0283 0284 /** 0285 * Gets the final time when this rule takes effect. 0286 * @param prevRawOffset The standard time offset from UTC before this rule 0287 * takes effect in milliseconds. 0288 * @param prevDSTSavings The amount of daylight saving offset from the 0289 * standard time. 0290 * @param result Receives the final time when this rule takes effect. 0291 * @return true if the start time is available. When false is returned, output parameter 0292 * "result" is unchanged. 0293 * @stable ICU 3.8 0294 */ 0295 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 0296 0297 /** 0298 * Gets the first time when this rule takes effect after the specified time. 0299 * @param base The first start time after this base time will be returned. 0300 * @param prevRawOffset The standard time offset from UTC before this rule 0301 * takes effect in milliseconds. 0302 * @param prevDSTSavings The amount of daylight saving offset from the 0303 * standard time. 0304 * @param inclusive Whether the base time is inclusive or not. 0305 * @param result Receives The first time when this rule takes effect after 0306 * the specified base time. 0307 * @return true if the start time is available. When false is returned, output parameter 0308 * "result" is unchanged. 0309 * @stable ICU 3.8 0310 */ 0311 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0312 UBool inclusive, UDate& result) const override; 0313 0314 /** 0315 * Gets the most recent time when this rule takes effect before the specified time. 0316 * @param base The most recent time before this base time will be returned. 0317 * @param prevRawOffset The standard time offset from UTC before this rule 0318 * takes effect in milliseconds. 0319 * @param prevDSTSavings The amount of daylight saving offset from the 0320 * standard time. 0321 * @param inclusive Whether the base time is inclusive or not. 0322 * @param result Receives The most recent time when this rule takes effect before 0323 * the specified base time. 0324 * @return true if the start time is available. When false is returned, output parameter 0325 * "result" is unchanged. 0326 * @stable ICU 3.8 0327 */ 0328 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0329 UBool inclusive, UDate& result) const override; 0330 0331 public: 0332 /** 0333 * Return the class ID for this class. This is useful only for comparing to 0334 * a return value from getDynamicClassID(). For example: 0335 * <pre> 0336 * . Base* polymorphic_pointer = createPolymorphicObject(); 0337 * . if (polymorphic_pointer->getDynamicClassID() == 0338 * . erived::getStaticClassID()) ... 0339 * </pre> 0340 * @return The class ID for all objects of this class. 0341 * @stable ICU 3.8 0342 */ 0343 static UClassID U_EXPORT2 getStaticClassID(void); 0344 0345 /** 0346 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 0347 * method is to implement a simple version of RTTI, since not all C++ 0348 * compilers support genuine RTTI. Polymorphic operator==() and clone() 0349 * methods call this method. 0350 * 0351 * @return The class ID for this object. All objects of a 0352 * given class have the same class ID. Objects of 0353 * other classes have different class IDs. 0354 * @stable ICU 3.8 0355 */ 0356 virtual UClassID getDynamicClassID(void) const override; 0357 }; 0358 0359 /** 0360 * <code>AnnualTimeZoneRule</code> is a class used for representing a time zone 0361 * rule which takes effect annually. The calendar system used for the rule is 0362 * is based on Gregorian calendar 0363 * 0364 * @stable ICU 3.8 0365 */ 0366 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule { 0367 public: 0368 /** 0369 * The constant representing the maximum year used for designating 0370 * a rule is permanent. 0371 */ 0372 static const int32_t MAX_YEAR; 0373 0374 /** 0375 * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its 0376 * standard time, the amount of daylight saving offset adjustment, the annual start 0377 * time rule and the start/until years. The input DateTimeRule is copied by this 0378 * constructor, so the caller remains responsible for deleting the object. 0379 * @param name The time zone name. 0380 * @param rawOffset The GMT offset of its standard time in milliseconds. 0381 * @param dstSavings The amount of daylight saving offset adjustment in 0382 * milliseconds. If this ia a rule for standard time, 0383 * the value of this argument is 0. 0384 * @param dateTimeRule The start date/time rule repeated annually. 0385 * @param startYear The first year when this rule takes effect. 0386 * @param endYear The last year when this rule takes effect. If this 0387 * rule is effective forever in future, specify MAX_YEAR. 0388 * @stable ICU 3.8 0389 */ 0390 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 0391 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear); 0392 0393 /** 0394 * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its 0395 * standard time, the amount of daylight saving offset adjustment, the annual start 0396 * time rule and the start/until years. The input DateTimeRule object is adopted 0397 * by this object, therefore, the caller must not delete the object. 0398 * @param name The time zone name. 0399 * @param rawOffset The GMT offset of its standard time in milliseconds. 0400 * @param dstSavings The amount of daylight saving offset adjustment in 0401 * milliseconds. If this ia a rule for standard time, 0402 * the value of this argument is 0. 0403 * @param dateTimeRule The start date/time rule repeated annually. 0404 * @param startYear The first year when this rule takes effect. 0405 * @param endYear The last year when this rule takes effect. If this 0406 * rule is effective forever in future, specify MAX_YEAR. 0407 * @stable ICU 3.8 0408 */ 0409 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 0410 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear); 0411 0412 /** 0413 * Copy constructor. 0414 * @param source The AnnualTimeZoneRule object to be copied. 0415 * @stable ICU 3.8 0416 */ 0417 AnnualTimeZoneRule(const AnnualTimeZoneRule& source); 0418 0419 /** 0420 * Destructor. 0421 * @stable ICU 3.8 0422 */ 0423 virtual ~AnnualTimeZoneRule(); 0424 0425 /** 0426 * Clone this AnnualTimeZoneRule object polymorphically. The caller owns the result and 0427 * should delete it when done. 0428 * @return A copy of the object. 0429 * @stable ICU 3.8 0430 */ 0431 virtual AnnualTimeZoneRule* clone() const override; 0432 0433 /** 0434 * Assignment operator. 0435 * @param right The object to be copied. 0436 * @stable ICU 3.8 0437 */ 0438 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right); 0439 0440 /** 0441 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 0442 * of different subclasses are considered unequal. 0443 * @param that The object to be compared with. 0444 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 0445 * @stable ICU 3.8 0446 */ 0447 virtual bool operator==(const TimeZoneRule& that) const override; 0448 0449 /** 0450 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 0451 * of different subclasses are considered unequal. 0452 * @param that The object to be compared with. 0453 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 0454 * @stable ICU 3.8 0455 */ 0456 virtual bool operator!=(const TimeZoneRule& that) const override; 0457 0458 /** 0459 * Gets the start date/time rule used by this rule. 0460 * @return The <code>AnnualDateTimeRule</code> which represents the start date/time 0461 * rule used by this time zone rule. 0462 * @stable ICU 3.8 0463 */ 0464 const DateTimeRule* getRule(void) const; 0465 0466 /** 0467 * Gets the first year when this rule takes effect. 0468 * @return The start year of this rule. The year is in Gregorian calendar 0469 * with 0 == 1 BCE, -1 == 2 BCE, etc. 0470 * @stable ICU 3.8 0471 */ 0472 int32_t getStartYear(void) const; 0473 0474 /** 0475 * Gets the end year when this rule takes effect. 0476 * @return The end year of this rule (inclusive). The year is in Gregorian calendar 0477 * with 0 == 1 BCE, -1 == 2 BCE, etc. 0478 * @stable ICU 3.8 0479 */ 0480 int32_t getEndYear(void) const; 0481 0482 /** 0483 * Gets the time when this rule takes effect in the given year. 0484 * @param year The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. 0485 * @param prevRawOffset The standard time offset from UTC before this rule 0486 * takes effect in milliseconds. 0487 * @param prevDSTSavings The amount of daylight saving offset from the 0488 * standard time. 0489 * @param result Receives the start time in the year. 0490 * @return true if this rule takes effect in the year and the result is set to 0491 * "result". 0492 * @stable ICU 3.8 0493 */ 0494 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const; 0495 0496 /** 0497 * Returns if this rule represents the same rule and offsets as another. 0498 * When two <code>TimeZoneRule</code> objects differ only its names, this method 0499 * returns true. 0500 * @param that The <code>TimeZoneRule</code> object to be compared with. 0501 * @return true if the other <code>TimeZoneRule</code> is equivalent to this one. 0502 * @stable ICU 3.8 0503 */ 0504 virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 0505 0506 /** 0507 * Gets the very first time when this rule takes effect. 0508 * @param prevRawOffset The standard time offset from UTC before this rule 0509 * takes effect in milliseconds. 0510 * @param prevDSTSavings The amount of daylight saving offset from the 0511 * standard time. 0512 * @param result Receives the very first time when this rule takes effect. 0513 * @return true if the start time is available. When false is returned, output parameter 0514 * "result" is unchanged. 0515 * @stable ICU 3.8 0516 */ 0517 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 0518 0519 /** 0520 * Gets the final time when this rule takes effect. 0521 * @param prevRawOffset The standard time offset from UTC before this rule 0522 * takes effect in milliseconds. 0523 * @param prevDSTSavings The amount of daylight saving offset from the 0524 * standard time. 0525 * @param result Receives the final time when this rule takes effect. 0526 * @return true if the start time is available. When false is returned, output parameter 0527 * "result" is unchanged. 0528 * @stable ICU 3.8 0529 */ 0530 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 0531 0532 /** 0533 * Gets the first time when this rule takes effect after the specified time. 0534 * @param base The first start time after this base time will be returned. 0535 * @param prevRawOffset The standard time offset from UTC before this rule 0536 * takes effect in milliseconds. 0537 * @param prevDSTSavings The amount of daylight saving offset from the 0538 * standard time. 0539 * @param inclusive Whether the base time is inclusive or not. 0540 * @param result Receives The first time when this rule takes effect after 0541 * the specified base time. 0542 * @return true if the start time is available. When false is returned, output parameter 0543 * "result" is unchanged. 0544 * @stable ICU 3.8 0545 */ 0546 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0547 UBool inclusive, UDate& result) const override; 0548 0549 /** 0550 * Gets the most recent time when this rule takes effect before the specified time. 0551 * @param base The most recent time before this base time will be returned. 0552 * @param prevRawOffset The standard time offset from UTC before this rule 0553 * takes effect in milliseconds. 0554 * @param prevDSTSavings The amount of daylight saving offset from the 0555 * standard time. 0556 * @param inclusive Whether the base time is inclusive or not. 0557 * @param result Receives The most recent time when this rule takes effect before 0558 * the specified base time. 0559 * @return true if the start time is available. When false is returned, output parameter 0560 * "result" is unchanged. 0561 * @stable ICU 3.8 0562 */ 0563 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0564 UBool inclusive, UDate& result) const override; 0565 0566 0567 private: 0568 DateTimeRule* fDateTimeRule; 0569 int32_t fStartYear; 0570 int32_t fEndYear; 0571 0572 public: 0573 /** 0574 * Return the class ID for this class. This is useful only for comparing to 0575 * a return value from getDynamicClassID(). For example: 0576 * <pre> 0577 * . Base* polymorphic_pointer = createPolymorphicObject(); 0578 * . if (polymorphic_pointer->getDynamicClassID() == 0579 * . erived::getStaticClassID()) ... 0580 * </pre> 0581 * @return The class ID for all objects of this class. 0582 * @stable ICU 3.8 0583 */ 0584 static UClassID U_EXPORT2 getStaticClassID(void); 0585 0586 /** 0587 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 0588 * method is to implement a simple version of RTTI, since not all C++ 0589 * compilers support genuine RTTI. Polymorphic operator==() and clone() 0590 * methods call this method. 0591 * 0592 * @return The class ID for this object. All objects of a 0593 * given class have the same class ID. Objects of 0594 * other classes have different class IDs. 0595 * @stable ICU 3.8 0596 */ 0597 virtual UClassID getDynamicClassID(void) const override; 0598 }; 0599 0600 /** 0601 * <code>TimeArrayTimeZoneRule</code> represents a time zone rule whose start times are 0602 * defined by an array of milliseconds since the standard base time. 0603 * 0604 * @stable ICU 3.8 0605 */ 0606 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule { 0607 public: 0608 /** 0609 * Constructs a <code>TimeArrayTimeZoneRule</code> with the name, the GMT offset of its 0610 * standard time, the amount of daylight saving offset adjustment and 0611 * the array of times when this rule takes effect. 0612 * @param name The time zone name. 0613 * @param rawOffset The UTC offset of its standard time in milliseconds. 0614 * @param dstSavings The amount of daylight saving offset adjustment in 0615 * milliseconds. If this ia a rule for standard time, 0616 * the value of this argument is 0. 0617 * @param startTimes The array start times in milliseconds since the base time 0618 * (January 1, 1970, 00:00:00). 0619 * @param numStartTimes The number of elements in the parameter "startTimes" 0620 * @param timeRuleType The time type of the start times, which is one of 0621 * <code>DataTimeRule::WALL_TIME</code>, <code>STANDARD_TIME</code> 0622 * and <code>UTC_TIME</code>. 0623 * @stable ICU 3.8 0624 */ 0625 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 0626 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType); 0627 0628 /** 0629 * Copy constructor. 0630 * @param source The TimeArrayTimeZoneRule object to be copied. 0631 * @stable ICU 3.8 0632 */ 0633 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source); 0634 0635 /** 0636 * Destructor. 0637 * @stable ICU 3.8 0638 */ 0639 virtual ~TimeArrayTimeZoneRule(); 0640 0641 /** 0642 * Clone this TimeArrayTimeZoneRule object polymorphically. The caller owns the result and 0643 * should delete it when done. 0644 * @return A copy of the object. 0645 * @stable ICU 3.8 0646 */ 0647 virtual TimeArrayTimeZoneRule* clone() const override; 0648 0649 /** 0650 * Assignment operator. 0651 * @param right The object to be copied. 0652 * @stable ICU 3.8 0653 */ 0654 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right); 0655 0656 /** 0657 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects 0658 * of different subclasses are considered unequal. 0659 * @param that The object to be compared with. 0660 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal. 0661 * @stable ICU 3.8 0662 */ 0663 virtual bool operator==(const TimeZoneRule& that) const override; 0664 0665 /** 0666 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects 0667 * of different subclasses are considered unequal. 0668 * @param that The object to be compared with. 0669 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal. 0670 * @stable ICU 3.8 0671 */ 0672 virtual bool operator!=(const TimeZoneRule& that) const override; 0673 0674 /** 0675 * Gets the time type of the start times used by this rule. The return value 0676 * is either <code>DateTimeRule::WALL_TIME</code> or <code>STANDARD_TIME</code> 0677 * or <code>UTC_TIME</code>. 0678 * 0679 * @return The time type used of the start times used by this rule. 0680 * @stable ICU 3.8 0681 */ 0682 DateTimeRule::TimeRuleType getTimeType(void) const; 0683 0684 /** 0685 * Gets a start time at the index stored in this rule. 0686 * @param index The index of start times 0687 * @param result Receives the start time at the index 0688 * @return true if the index is within the valid range and 0689 * and the result is set. When false, the output 0690 * parameger "result" is unchanged. 0691 * @stable ICU 3.8 0692 */ 0693 UBool getStartTimeAt(int32_t index, UDate& result) const; 0694 0695 /** 0696 * Returns the number of start times stored in this rule 0697 * @return The number of start times. 0698 * @stable ICU 3.8 0699 */ 0700 int32_t countStartTimes(void) const; 0701 0702 /** 0703 * Returns if this rule represents the same rule and offsets as another. 0704 * When two <code>TimeZoneRule</code> objects differ only its names, this method 0705 * returns true. 0706 * @param that The <code>TimeZoneRule</code> object to be compared with. 0707 * @return true if the other <code>TimeZoneRule</code> is equivalent to this one. 0708 * @stable ICU 3.8 0709 */ 0710 virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 0711 0712 /** 0713 * Gets the very first time when this rule takes effect. 0714 * @param prevRawOffset The standard time offset from UTC before this rule 0715 * takes effect in milliseconds. 0716 * @param prevDSTSavings The amount of daylight saving offset from the 0717 * standard time. 0718 * @param result Receives the very first time when this rule takes effect. 0719 * @return true if the start time is available. When false is returned, output parameter 0720 * "result" is unchanged. 0721 * @stable ICU 3.8 0722 */ 0723 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 0724 0725 /** 0726 * Gets the final time when this rule takes effect. 0727 * @param prevRawOffset The standard time offset from UTC before this rule 0728 * takes effect in milliseconds. 0729 * @param prevDSTSavings The amount of daylight saving offset from the 0730 * standard time. 0731 * @param result Receives the final time when this rule takes effect. 0732 * @return true if the start time is available. When false is returned, output parameter 0733 * "result" is unchanged. 0734 * @stable ICU 3.8 0735 */ 0736 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 0737 0738 /** 0739 * Gets the first time when this rule takes effect after the specified time. 0740 * @param base The first start time after this base time will be returned. 0741 * @param prevRawOffset The standard time offset from UTC before this rule 0742 * takes effect in milliseconds. 0743 * @param prevDSTSavings The amount of daylight saving offset from the 0744 * standard time. 0745 * @param inclusive Whether the base time is inclusive or not. 0746 * @param result Receives The first time when this rule takes effect after 0747 * the specified base time. 0748 * @return true if the start time is available. When false is returned, output parameter 0749 * "result" is unchanged. 0750 * @stable ICU 3.8 0751 */ 0752 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0753 UBool inclusive, UDate& result) const override; 0754 0755 /** 0756 * Gets the most recent time when this rule takes effect before the specified time. 0757 * @param base The most recent time before this base time will be returned. 0758 * @param prevRawOffset The standard time offset from UTC before this rule 0759 * takes effect in milliseconds. 0760 * @param prevDSTSavings The amount of daylight saving offset from the 0761 * standard time. 0762 * @param inclusive Whether the base time is inclusive or not. 0763 * @param result Receives The most recent time when this rule takes effect before 0764 * the specified base time. 0765 * @return true if the start time is available. When false is returned, output parameter 0766 * "result" is unchanged. 0767 * @stable ICU 3.8 0768 */ 0769 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 0770 UBool inclusive, UDate& result) const override; 0771 0772 0773 private: 0774 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 }; 0775 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec); 0776 UDate getUTC(UDate time, int32_t raw, int32_t dst) const; 0777 0778 DateTimeRule::TimeRuleType fTimeRuleType; 0779 int32_t fNumStartTimes; 0780 UDate* fStartTimes; 0781 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE]; 0782 0783 public: 0784 /** 0785 * Return the class ID for this class. This is useful only for comparing to 0786 * a return value from getDynamicClassID(). For example: 0787 * <pre> 0788 * . Base* polymorphic_pointer = createPolymorphicObject(); 0789 * . if (polymorphic_pointer->getDynamicClassID() == 0790 * . erived::getStaticClassID()) ... 0791 * </pre> 0792 * @return The class ID for all objects of this class. 0793 * @stable ICU 3.8 0794 */ 0795 static UClassID U_EXPORT2 getStaticClassID(void); 0796 0797 /** 0798 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 0799 * method is to implement a simple version of RTTI, since not all C++ 0800 * compilers support genuine RTTI. Polymorphic operator==() and clone() 0801 * methods call this method. 0802 * 0803 * @return The class ID for this object. All objects of a 0804 * given class have the same class ID. Objects of 0805 * other classes have different class IDs. 0806 * @stable ICU 3.8 0807 */ 0808 virtual UClassID getDynamicClassID(void) const override; 0809 }; 0810 0811 0812 U_NAMESPACE_END 0813 0814 #endif /* #if !UCONFIG_NO_FORMATTING */ 0815 0816 #endif /* U_SHOW_CPLUSPLUS_API */ 0817 0818 #endif // TZRULE_H 0819 0820 //eof
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |