Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************** |
michael@0 | 3 | * Copyright (C) 1997-2013, International Business Machines * |
michael@0 | 4 | * Corporation and others. All Rights Reserved. * |
michael@0 | 5 | ******************************************************************************** |
michael@0 | 6 | * |
michael@0 | 7 | * File SIMPLETZ.H |
michael@0 | 8 | * |
michael@0 | 9 | * Modification History: |
michael@0 | 10 | * |
michael@0 | 11 | * Date Name Description |
michael@0 | 12 | * 04/21/97 aliu Overhauled header. |
michael@0 | 13 | * 08/10/98 stephen JDK 1.2 sync |
michael@0 | 14 | * Added setStartRule() / setEndRule() overloads |
michael@0 | 15 | * Added hasSameRules() |
michael@0 | 16 | * 09/02/98 stephen Added getOffset(monthLen) |
michael@0 | 17 | * Changed getOffset() to take UErrorCode |
michael@0 | 18 | * 07/09/99 stephen Removed millisPerHour (unused, for HP compiler) |
michael@0 | 19 | * 12/02/99 aliu Added TimeMode and constructor and setStart/EndRule |
michael@0 | 20 | * methods that take TimeMode. Added to docs. |
michael@0 | 21 | ******************************************************************************** |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | #ifndef SIMPLETZ_H |
michael@0 | 25 | #define SIMPLETZ_H |
michael@0 | 26 | |
michael@0 | 27 | #include "unicode/utypes.h" |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * \file |
michael@0 | 31 | * \brief C++ API: SimpleTimeZone is a concrete subclass of TimeZone. |
michael@0 | 32 | */ |
michael@0 | 33 | |
michael@0 | 34 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 35 | |
michael@0 | 36 | #include "unicode/basictz.h" |
michael@0 | 37 | |
michael@0 | 38 | U_NAMESPACE_BEGIN |
michael@0 | 39 | |
michael@0 | 40 | // forward declaration |
michael@0 | 41 | class InitialTimeZoneRule; |
michael@0 | 42 | class TimeZoneTransition; |
michael@0 | 43 | class AnnualTimeZoneRule; |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * <code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code> |
michael@0 | 47 | * that represents a time zone for use with a Gregorian calendar. This |
michael@0 | 48 | * class does not handle historical changes. |
michael@0 | 49 | * <P> |
michael@0 | 50 | * When specifying daylight-savings-time begin and end dates, use a negative value for |
michael@0 | 51 | * <code>dayOfWeekInMonth</code> to indicate that <code>SimpleTimeZone</code> should |
michael@0 | 52 | * count from the end of the month backwards. For example, if Daylight Savings |
michael@0 | 53 | * Time starts or ends at the last Sunday a month, use <code>dayOfWeekInMonth = -1</code> |
michael@0 | 54 | * along with <code>dayOfWeek = UCAL_SUNDAY</code> to specify the rule. |
michael@0 | 55 | * |
michael@0 | 56 | * @see Calendar |
michael@0 | 57 | * @see GregorianCalendar |
michael@0 | 58 | * @see TimeZone |
michael@0 | 59 | * @author D. Goldsmith, Mark Davis, Chen-Lieh Huang, Alan Liu |
michael@0 | 60 | */ |
michael@0 | 61 | class U_I18N_API SimpleTimeZone: public BasicTimeZone { |
michael@0 | 62 | public: |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * TimeMode is used, together with a millisecond offset after |
michael@0 | 66 | * midnight, to specify a rule transition time. Most rules |
michael@0 | 67 | * transition at a local wall time, that is, according to the |
michael@0 | 68 | * current time in effect, either standard, or DST. However, some |
michael@0 | 69 | * rules transition at local standard time, and some at a specific |
michael@0 | 70 | * UTC time. Although it might seem that all times could be |
michael@0 | 71 | * converted to wall time, thus eliminating the need for this |
michael@0 | 72 | * parameter, this is not the case. |
michael@0 | 73 | * @stable ICU 2.0 |
michael@0 | 74 | */ |
michael@0 | 75 | enum TimeMode { |
michael@0 | 76 | WALL_TIME = 0, |
michael@0 | 77 | STANDARD_TIME, |
michael@0 | 78 | UTC_TIME |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | /** |
michael@0 | 82 | * Copy constructor |
michael@0 | 83 | * @param source the object to be copied. |
michael@0 | 84 | * @stable ICU 2.0 |
michael@0 | 85 | */ |
michael@0 | 86 | SimpleTimeZone(const SimpleTimeZone& source); |
michael@0 | 87 | |
michael@0 | 88 | /** |
michael@0 | 89 | * Default assignment operator |
michael@0 | 90 | * @param right the object to be copied. |
michael@0 | 91 | * @stable ICU 2.0 |
michael@0 | 92 | */ |
michael@0 | 93 | SimpleTimeZone& operator=(const SimpleTimeZone& right); |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Destructor |
michael@0 | 97 | * @stable ICU 2.0 |
michael@0 | 98 | */ |
michael@0 | 99 | virtual ~SimpleTimeZone(); |
michael@0 | 100 | |
michael@0 | 101 | /** |
michael@0 | 102 | * Returns true if the two TimeZone objects are equal; that is, they have |
michael@0 | 103 | * the same ID, raw GMT offset, and DST rules. |
michael@0 | 104 | * |
michael@0 | 105 | * @param that The SimpleTimeZone object to be compared with. |
michael@0 | 106 | * @return True if the given time zone is equal to this time zone; false |
michael@0 | 107 | * otherwise. |
michael@0 | 108 | * @stable ICU 2.0 |
michael@0 | 109 | */ |
michael@0 | 110 | virtual UBool operator==(const TimeZone& that) const; |
michael@0 | 111 | |
michael@0 | 112 | /** |
michael@0 | 113 | * Constructs a SimpleTimeZone with the given raw GMT offset and time zone ID, |
michael@0 | 114 | * and which doesn't observe daylight savings time. Normally you should use |
michael@0 | 115 | * TimeZone::createInstance() to create a TimeZone instead of creating a |
michael@0 | 116 | * SimpleTimeZone directly with this constructor. |
michael@0 | 117 | * |
michael@0 | 118 | * @param rawOffsetGMT The given base time zone offset to GMT. |
michael@0 | 119 | * @param ID The timezone ID which is obtained from |
michael@0 | 120 | * TimeZone.getAvailableIDs. |
michael@0 | 121 | * @stable ICU 2.0 |
michael@0 | 122 | */ |
michael@0 | 123 | SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID); |
michael@0 | 124 | |
michael@0 | 125 | /** |
michael@0 | 126 | * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID, |
michael@0 | 127 | * and times to start and end daylight savings time. To create a TimeZone that |
michael@0 | 128 | * doesn't observe daylight savings time, don't use this constructor; use |
michael@0 | 129 | * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use |
michael@0 | 130 | * TimeZone.createInstance() to create a TimeZone instead of creating a |
michael@0 | 131 | * SimpleTimeZone directly with this constructor. |
michael@0 | 132 | * <P> |
michael@0 | 133 | * Various types of daylight-savings time rules can be specfied by using different |
michael@0 | 134 | * values for startDay and startDayOfWeek and endDay and endDayOfWeek. For a |
michael@0 | 135 | * complete explanation of how these parameters work, see the documentation for |
michael@0 | 136 | * setStartRule(). |
michael@0 | 137 | * |
michael@0 | 138 | * @param rawOffsetGMT The new SimpleTimeZone's raw GMT offset |
michael@0 | 139 | * @param ID The new SimpleTimeZone's time zone ID. |
michael@0 | 140 | * @param savingsStartMonth The daylight savings starting month. Month is |
michael@0 | 141 | * 0-based. eg, 0 for January. |
michael@0 | 142 | * @param savingsStartDayOfWeekInMonth The daylight savings starting |
michael@0 | 143 | * day-of-week-in-month. See setStartRule() for a |
michael@0 | 144 | * complete explanation. |
michael@0 | 145 | * @param savingsStartDayOfWeek The daylight savings starting day-of-week. |
michael@0 | 146 | * See setStartRule() for a complete explanation. |
michael@0 | 147 | * @param savingsStartTime The daylight savings starting time, expressed as the |
michael@0 | 148 | * number of milliseconds after midnight. |
michael@0 | 149 | * @param savingsEndMonth The daylight savings ending month. Month is |
michael@0 | 150 | * 0-based. eg, 0 for January. |
michael@0 | 151 | * @param savingsEndDayOfWeekInMonth The daylight savings ending day-of-week-in-month. |
michael@0 | 152 | * See setStartRule() for a complete explanation. |
michael@0 | 153 | * @param savingsEndDayOfWeek The daylight savings ending day-of-week. |
michael@0 | 154 | * See setStartRule() for a complete explanation. |
michael@0 | 155 | * @param savingsEndTime The daylight savings ending time, expressed as the |
michael@0 | 156 | * number of milliseconds after midnight. |
michael@0 | 157 | * @param status An UErrorCode to receive the status. |
michael@0 | 158 | * @stable ICU 2.0 |
michael@0 | 159 | */ |
michael@0 | 160 | SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, |
michael@0 | 161 | int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, |
michael@0 | 162 | int8_t savingsStartDayOfWeek, int32_t savingsStartTime, |
michael@0 | 163 | int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, |
michael@0 | 164 | int8_t savingsEndDayOfWeek, int32_t savingsEndTime, |
michael@0 | 165 | UErrorCode& status); |
michael@0 | 166 | /** |
michael@0 | 167 | * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID, |
michael@0 | 168 | * and times to start and end daylight savings time. To create a TimeZone that |
michael@0 | 169 | * doesn't observe daylight savings time, don't use this constructor; use |
michael@0 | 170 | * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use |
michael@0 | 171 | * TimeZone.createInstance() to create a TimeZone instead of creating a |
michael@0 | 172 | * SimpleTimeZone directly with this constructor. |
michael@0 | 173 | * <P> |
michael@0 | 174 | * Various types of daylight-savings time rules can be specfied by using different |
michael@0 | 175 | * values for startDay and startDayOfWeek and endDay and endDayOfWeek. For a |
michael@0 | 176 | * complete explanation of how these parameters work, see the documentation for |
michael@0 | 177 | * setStartRule(). |
michael@0 | 178 | * |
michael@0 | 179 | * @param rawOffsetGMT The new SimpleTimeZone's raw GMT offset |
michael@0 | 180 | * @param ID The new SimpleTimeZone's time zone ID. |
michael@0 | 181 | * @param savingsStartMonth The daylight savings starting month. Month is |
michael@0 | 182 | * 0-based. eg, 0 for January. |
michael@0 | 183 | * @param savingsStartDayOfWeekInMonth The daylight savings starting |
michael@0 | 184 | * day-of-week-in-month. See setStartRule() for a |
michael@0 | 185 | * complete explanation. |
michael@0 | 186 | * @param savingsStartDayOfWeek The daylight savings starting day-of-week. |
michael@0 | 187 | * See setStartRule() for a complete explanation. |
michael@0 | 188 | * @param savingsStartTime The daylight savings starting time, expressed as the |
michael@0 | 189 | * number of milliseconds after midnight. |
michael@0 | 190 | * @param savingsEndMonth The daylight savings ending month. Month is |
michael@0 | 191 | * 0-based. eg, 0 for January. |
michael@0 | 192 | * @param savingsEndDayOfWeekInMonth The daylight savings ending day-of-week-in-month. |
michael@0 | 193 | * See setStartRule() for a complete explanation. |
michael@0 | 194 | * @param savingsEndDayOfWeek The daylight savings ending day-of-week. |
michael@0 | 195 | * See setStartRule() for a complete explanation. |
michael@0 | 196 | * @param savingsEndTime The daylight savings ending time, expressed as the |
michael@0 | 197 | * number of milliseconds after midnight. |
michael@0 | 198 | * @param savingsDST The number of milliseconds added to standard time |
michael@0 | 199 | * to get DST time. Default is one hour. |
michael@0 | 200 | * @param status An UErrorCode to receive the status. |
michael@0 | 201 | * @stable ICU 2.0 |
michael@0 | 202 | */ |
michael@0 | 203 | SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, |
michael@0 | 204 | int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, |
michael@0 | 205 | int8_t savingsStartDayOfWeek, int32_t savingsStartTime, |
michael@0 | 206 | int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, |
michael@0 | 207 | int8_t savingsEndDayOfWeek, int32_t savingsEndTime, |
michael@0 | 208 | int32_t savingsDST, UErrorCode& status); |
michael@0 | 209 | |
michael@0 | 210 | /** |
michael@0 | 211 | * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID, |
michael@0 | 212 | * and times to start and end daylight savings time. To create a TimeZone that |
michael@0 | 213 | * doesn't observe daylight savings time, don't use this constructor; use |
michael@0 | 214 | * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use |
michael@0 | 215 | * TimeZone.createInstance() to create a TimeZone instead of creating a |
michael@0 | 216 | * SimpleTimeZone directly with this constructor. |
michael@0 | 217 | * <P> |
michael@0 | 218 | * Various types of daylight-savings time rules can be specfied by using different |
michael@0 | 219 | * values for startDay and startDayOfWeek and endDay and endDayOfWeek. For a |
michael@0 | 220 | * complete explanation of how these parameters work, see the documentation for |
michael@0 | 221 | * setStartRule(). |
michael@0 | 222 | * |
michael@0 | 223 | * @param rawOffsetGMT The new SimpleTimeZone's raw GMT offset |
michael@0 | 224 | * @param ID The new SimpleTimeZone's time zone ID. |
michael@0 | 225 | * @param savingsStartMonth The daylight savings starting month. Month is |
michael@0 | 226 | * 0-based. eg, 0 for January. |
michael@0 | 227 | * @param savingsStartDayOfWeekInMonth The daylight savings starting |
michael@0 | 228 | * day-of-week-in-month. See setStartRule() for a |
michael@0 | 229 | * complete explanation. |
michael@0 | 230 | * @param savingsStartDayOfWeek The daylight savings starting day-of-week. |
michael@0 | 231 | * See setStartRule() for a complete explanation. |
michael@0 | 232 | * @param savingsStartTime The daylight savings starting time, expressed as the |
michael@0 | 233 | * number of milliseconds after midnight. |
michael@0 | 234 | * @param savingsStartTimeMode Whether the start time is local wall time, local |
michael@0 | 235 | * standard time, or UTC time. Default is local wall time. |
michael@0 | 236 | * @param savingsEndMonth The daylight savings ending month. Month is |
michael@0 | 237 | * 0-based. eg, 0 for January. |
michael@0 | 238 | * @param savingsEndDayOfWeekInMonth The daylight savings ending day-of-week-in-month. |
michael@0 | 239 | * See setStartRule() for a complete explanation. |
michael@0 | 240 | * @param savingsEndDayOfWeek The daylight savings ending day-of-week. |
michael@0 | 241 | * See setStartRule() for a complete explanation. |
michael@0 | 242 | * @param savingsEndTime The daylight savings ending time, expressed as the |
michael@0 | 243 | * number of milliseconds after midnight. |
michael@0 | 244 | * @param savingsEndTimeMode Whether the end time is local wall time, local |
michael@0 | 245 | * standard time, or UTC time. Default is local wall time. |
michael@0 | 246 | * @param savingsDST The number of milliseconds added to standard time |
michael@0 | 247 | * to get DST time. Default is one hour. |
michael@0 | 248 | * @param status An UErrorCode to receive the status. |
michael@0 | 249 | * @stable ICU 2.0 |
michael@0 | 250 | */ |
michael@0 | 251 | SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, |
michael@0 | 252 | int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, |
michael@0 | 253 | int8_t savingsStartDayOfWeek, int32_t savingsStartTime, |
michael@0 | 254 | TimeMode savingsStartTimeMode, |
michael@0 | 255 | int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, |
michael@0 | 256 | int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode, |
michael@0 | 257 | int32_t savingsDST, UErrorCode& status); |
michael@0 | 258 | |
michael@0 | 259 | /** |
michael@0 | 260 | * Sets the daylight savings starting year, that is, the year this time zone began |
michael@0 | 261 | * observing its specified daylight savings time rules. The time zone is considered |
michael@0 | 262 | * not to observe daylight savings time prior to that year; SimpleTimeZone doesn't |
michael@0 | 263 | * support historical daylight-savings-time rules. |
michael@0 | 264 | * @param year the daylight savings starting year. |
michael@0 | 265 | * @stable ICU 2.0 |
michael@0 | 266 | */ |
michael@0 | 267 | void setStartYear(int32_t year); |
michael@0 | 268 | |
michael@0 | 269 | /** |
michael@0 | 270 | * Sets the daylight savings starting rule. For example, in the U.S., Daylight Savings |
michael@0 | 271 | * Time starts at the second Sunday in March, at 2 AM in standard time. |
michael@0 | 272 | * Therefore, you can set the start rule by calling: |
michael@0 | 273 | * setStartRule(UCAL_MARCH, 2, UCAL_SUNDAY, 2*60*60*1000); |
michael@0 | 274 | * The dayOfWeekInMonth and dayOfWeek parameters together specify how to calculate |
michael@0 | 275 | * the exact starting date. Their exact meaning depend on their respective signs, |
michael@0 | 276 | * allowing various types of rules to be constructed, as follows: |
michael@0 | 277 | * <ul> |
michael@0 | 278 | * <li>If both dayOfWeekInMonth and dayOfWeek are positive, they specify the |
michael@0 | 279 | * day of week in the month (e.g., (2, WEDNESDAY) is the second Wednesday |
michael@0 | 280 | * of the month).</li> |
michael@0 | 281 | * <li>If dayOfWeek is positive and dayOfWeekInMonth is negative, they specify |
michael@0 | 282 | * the day of week in the month counting backward from the end of the month. |
michael@0 | 283 | * (e.g., (-1, MONDAY) is the last Monday in the month)</li> |
michael@0 | 284 | * <li>If dayOfWeek is zero and dayOfWeekInMonth is positive, dayOfWeekInMonth |
michael@0 | 285 | * specifies the day of the month, regardless of what day of the week it is. |
michael@0 | 286 | * (e.g., (10, 0) is the tenth day of the month)</li> |
michael@0 | 287 | * <li>If dayOfWeek is zero and dayOfWeekInMonth is negative, dayOfWeekInMonth |
michael@0 | 288 | * specifies the day of the month counting backward from the end of the |
michael@0 | 289 | * month, regardless of what day of the week it is (e.g., (-2, 0) is the |
michael@0 | 290 | * next-to-last day of the month).</li> |
michael@0 | 291 | * <li>If dayOfWeek is negative and dayOfWeekInMonth is positive, they specify the |
michael@0 | 292 | * first specified day of the week on or after the specfied day of the month. |
michael@0 | 293 | * (e.g., (15, -SUNDAY) is the first Sunday after the 15th of the month |
michael@0 | 294 | * [or the 15th itself if the 15th is a Sunday].)</li> |
michael@0 | 295 | * <li>If dayOfWeek and DayOfWeekInMonth are both negative, they specify the |
michael@0 | 296 | * last specified day of the week on or before the specified day of the month. |
michael@0 | 297 | * (e.g., (-20, -TUESDAY) is the last Tuesday before the 20th of the month |
michael@0 | 298 | * [or the 20th itself if the 20th is a Tuesday].)</li> |
michael@0 | 299 | * </ul> |
michael@0 | 300 | * @param month the daylight savings starting month. Month is 0-based. |
michael@0 | 301 | * eg, 0 for January. |
michael@0 | 302 | * @param dayOfWeekInMonth the daylight savings starting |
michael@0 | 303 | * day-of-week-in-month. Please see the member description for an example. |
michael@0 | 304 | * @param dayOfWeek the daylight savings starting day-of-week. Please see |
michael@0 | 305 | * the member description for an example. |
michael@0 | 306 | * @param time the daylight savings starting time. Please see the member |
michael@0 | 307 | * description for an example. |
michael@0 | 308 | * @param status An UErrorCode |
michael@0 | 309 | * @stable ICU 2.0 |
michael@0 | 310 | */ |
michael@0 | 311 | void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, |
michael@0 | 312 | int32_t time, UErrorCode& status); |
michael@0 | 313 | /** |
michael@0 | 314 | * Sets the daylight savings starting rule. For example, in the U.S., Daylight Savings |
michael@0 | 315 | * Time starts at the second Sunday in March, at 2 AM in standard time. |
michael@0 | 316 | * Therefore, you can set the start rule by calling: |
michael@0 | 317 | * setStartRule(UCAL_MARCH, 2, UCAL_SUNDAY, 2*60*60*1000); |
michael@0 | 318 | * The dayOfWeekInMonth and dayOfWeek parameters together specify how to calculate |
michael@0 | 319 | * the exact starting date. Their exact meaning depend on their respective signs, |
michael@0 | 320 | * allowing various types of rules to be constructed, as follows: |
michael@0 | 321 | * <ul> |
michael@0 | 322 | * <li>If both dayOfWeekInMonth and dayOfWeek are positive, they specify the |
michael@0 | 323 | * day of week in the month (e.g., (2, WEDNESDAY) is the second Wednesday |
michael@0 | 324 | * of the month).</li> |
michael@0 | 325 | * <li>If dayOfWeek is positive and dayOfWeekInMonth is negative, they specify |
michael@0 | 326 | * the day of week in the month counting backward from the end of the month. |
michael@0 | 327 | * (e.g., (-1, MONDAY) is the last Monday in the month)</li> |
michael@0 | 328 | * <li>If dayOfWeek is zero and dayOfWeekInMonth is positive, dayOfWeekInMonth |
michael@0 | 329 | * specifies the day of the month, regardless of what day of the week it is. |
michael@0 | 330 | * (e.g., (10, 0) is the tenth day of the month)</li> |
michael@0 | 331 | * <li>If dayOfWeek is zero and dayOfWeekInMonth is negative, dayOfWeekInMonth |
michael@0 | 332 | * specifies the day of the month counting backward from the end of the |
michael@0 | 333 | * month, regardless of what day of the week it is (e.g., (-2, 0) is the |
michael@0 | 334 | * next-to-last day of the month).</li> |
michael@0 | 335 | * <li>If dayOfWeek is negative and dayOfWeekInMonth is positive, they specify the |
michael@0 | 336 | * first specified day of the week on or after the specfied day of the month. |
michael@0 | 337 | * (e.g., (15, -SUNDAY) is the first Sunday after the 15th of the month |
michael@0 | 338 | * [or the 15th itself if the 15th is a Sunday].)</li> |
michael@0 | 339 | * <li>If dayOfWeek and DayOfWeekInMonth are both negative, they specify the |
michael@0 | 340 | * last specified day of the week on or before the specified day of the month. |
michael@0 | 341 | * (e.g., (-20, -TUESDAY) is the last Tuesday before the 20th of the month |
michael@0 | 342 | * [or the 20th itself if the 20th is a Tuesday].)</li> |
michael@0 | 343 | * </ul> |
michael@0 | 344 | * @param month the daylight savings starting month. Month is 0-based. |
michael@0 | 345 | * eg, 0 for January. |
michael@0 | 346 | * @param dayOfWeekInMonth the daylight savings starting |
michael@0 | 347 | * day-of-week-in-month. Please see the member description for an example. |
michael@0 | 348 | * @param dayOfWeek the daylight savings starting day-of-week. Please see |
michael@0 | 349 | * the member description for an example. |
michael@0 | 350 | * @param time the daylight savings starting time. Please see the member |
michael@0 | 351 | * description for an example. |
michael@0 | 352 | * @param mode whether the time is local wall time, local standard time, |
michael@0 | 353 | * or UTC time. Default is local wall time. |
michael@0 | 354 | * @param status An UErrorCode |
michael@0 | 355 | * @stable ICU 2.0 |
michael@0 | 356 | */ |
michael@0 | 357 | void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, |
michael@0 | 358 | int32_t time, TimeMode mode, UErrorCode& status); |
michael@0 | 359 | |
michael@0 | 360 | /** |
michael@0 | 361 | * Sets the DST start rule to a fixed date within a month. |
michael@0 | 362 | * |
michael@0 | 363 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 364 | * @param dayOfMonth The date in that month (1-based). |
michael@0 | 365 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 366 | * when DST takes effect in local wall time, which is |
michael@0 | 367 | * standard time in this case. |
michael@0 | 368 | * @param status An UErrorCode |
michael@0 | 369 | * @stable ICU 2.0 |
michael@0 | 370 | */ |
michael@0 | 371 | void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, |
michael@0 | 372 | UErrorCode& status); |
michael@0 | 373 | /** |
michael@0 | 374 | * Sets the DST start rule to a fixed date within a month. |
michael@0 | 375 | * |
michael@0 | 376 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 377 | * @param dayOfMonth The date in that month (1-based). |
michael@0 | 378 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 379 | * when DST takes effect in local wall time, which is |
michael@0 | 380 | * standard time in this case. |
michael@0 | 381 | * @param mode whether the time is local wall time, local standard time, |
michael@0 | 382 | * or UTC time. Default is local wall time. |
michael@0 | 383 | * @param status An UErrorCode |
michael@0 | 384 | * @stable ICU 2.0 |
michael@0 | 385 | */ |
michael@0 | 386 | void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, |
michael@0 | 387 | TimeMode mode, UErrorCode& status); |
michael@0 | 388 | |
michael@0 | 389 | /** |
michael@0 | 390 | * Sets the DST start rule to a weekday before or after a give date within |
michael@0 | 391 | * a month, e.g., the first Monday on or after the 8th. |
michael@0 | 392 | * |
michael@0 | 393 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 394 | * @param dayOfMonth A date within that month (1-based). |
michael@0 | 395 | * @param dayOfWeek The day of the week on which this rule occurs. |
michael@0 | 396 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 397 | * when DST takes effect in local wall time, which is |
michael@0 | 398 | * standard time in this case. |
michael@0 | 399 | * @param after If true, this rule selects the first dayOfWeek on |
michael@0 | 400 | * or after dayOfMonth. If false, this rule selects |
michael@0 | 401 | * the last dayOfWeek on or before dayOfMonth. |
michael@0 | 402 | * @param status An UErrorCode |
michael@0 | 403 | * @stable ICU 2.0 |
michael@0 | 404 | */ |
michael@0 | 405 | void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, |
michael@0 | 406 | int32_t time, UBool after, UErrorCode& status); |
michael@0 | 407 | /** |
michael@0 | 408 | * Sets the DST start rule to a weekday before or after a give date within |
michael@0 | 409 | * a month, e.g., the first Monday on or after the 8th. |
michael@0 | 410 | * |
michael@0 | 411 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 412 | * @param dayOfMonth A date within that month (1-based). |
michael@0 | 413 | * @param dayOfWeek The day of the week on which this rule occurs. |
michael@0 | 414 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 415 | * when DST takes effect in local wall time, which is |
michael@0 | 416 | * standard time in this case. |
michael@0 | 417 | * @param mode whether the time is local wall time, local standard time, |
michael@0 | 418 | * or UTC time. Default is local wall time. |
michael@0 | 419 | * @param after If true, this rule selects the first dayOfWeek on |
michael@0 | 420 | * or after dayOfMonth. If false, this rule selects |
michael@0 | 421 | * the last dayOfWeek on or before dayOfMonth. |
michael@0 | 422 | * @param status An UErrorCode |
michael@0 | 423 | * @stable ICU 2.0 |
michael@0 | 424 | */ |
michael@0 | 425 | void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, |
michael@0 | 426 | int32_t time, TimeMode mode, UBool after, UErrorCode& status); |
michael@0 | 427 | |
michael@0 | 428 | /** |
michael@0 | 429 | * Sets the daylight savings ending rule. For example, if Daylight |
michael@0 | 430 | * Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time. |
michael@0 | 431 | * Therefore, you can set the end rule by calling: |
michael@0 | 432 | * <pre> |
michael@0 | 433 | * setEndRule(UCAL_OCTOBER, -1, UCAL_SUNDAY, 2*60*60*1000); |
michael@0 | 434 | * </pre> |
michael@0 | 435 | * Various other types of rules can be specified by manipulating the dayOfWeek |
michael@0 | 436 | * and dayOfWeekInMonth parameters. For complete details, see the documentation |
michael@0 | 437 | * for setStartRule(). |
michael@0 | 438 | * |
michael@0 | 439 | * @param month the daylight savings ending month. Month is 0-based. |
michael@0 | 440 | * eg, 0 for January. |
michael@0 | 441 | * @param dayOfWeekInMonth the daylight savings ending |
michael@0 | 442 | * day-of-week-in-month. See setStartRule() for a complete explanation. |
michael@0 | 443 | * @param dayOfWeek the daylight savings ending day-of-week. See setStartRule() |
michael@0 | 444 | * for a complete explanation. |
michael@0 | 445 | * @param time the daylight savings ending time. Please see the member |
michael@0 | 446 | * description for an example. |
michael@0 | 447 | * @param status An UErrorCode |
michael@0 | 448 | * @stable ICU 2.0 |
michael@0 | 449 | */ |
michael@0 | 450 | void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, |
michael@0 | 451 | int32_t time, UErrorCode& status); |
michael@0 | 452 | |
michael@0 | 453 | /** |
michael@0 | 454 | * Sets the daylight savings ending rule. For example, if Daylight |
michael@0 | 455 | * Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time. |
michael@0 | 456 | * Therefore, you can set the end rule by calling: |
michael@0 | 457 | * <pre> |
michael@0 | 458 | * setEndRule(UCAL_OCTOBER, -1, UCAL_SUNDAY, 2*60*60*1000); |
michael@0 | 459 | * </pre> |
michael@0 | 460 | * Various other types of rules can be specified by manipulating the dayOfWeek |
michael@0 | 461 | * and dayOfWeekInMonth parameters. For complete details, see the documentation |
michael@0 | 462 | * for setStartRule(). |
michael@0 | 463 | * |
michael@0 | 464 | * @param month the daylight savings ending month. Month is 0-based. |
michael@0 | 465 | * eg, 0 for January. |
michael@0 | 466 | * @param dayOfWeekInMonth the daylight savings ending |
michael@0 | 467 | * day-of-week-in-month. See setStartRule() for a complete explanation. |
michael@0 | 468 | * @param dayOfWeek the daylight savings ending day-of-week. See setStartRule() |
michael@0 | 469 | * for a complete explanation. |
michael@0 | 470 | * @param time the daylight savings ending time. Please see the member |
michael@0 | 471 | * description for an example. |
michael@0 | 472 | * @param mode whether the time is local wall time, local standard time, |
michael@0 | 473 | * or UTC time. Default is local wall time. |
michael@0 | 474 | * @param status An UErrorCode |
michael@0 | 475 | * @stable ICU 2.0 |
michael@0 | 476 | */ |
michael@0 | 477 | void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, |
michael@0 | 478 | int32_t time, TimeMode mode, UErrorCode& status); |
michael@0 | 479 | |
michael@0 | 480 | /** |
michael@0 | 481 | * Sets the DST end rule to a fixed date within a month. |
michael@0 | 482 | * |
michael@0 | 483 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 484 | * @param dayOfMonth The date in that month (1-based). |
michael@0 | 485 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 486 | * when DST ends in local wall time, which is daylight |
michael@0 | 487 | * time in this case. |
michael@0 | 488 | * @param status An UErrorCode |
michael@0 | 489 | * @stable ICU 2.0 |
michael@0 | 490 | */ |
michael@0 | 491 | void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status); |
michael@0 | 492 | |
michael@0 | 493 | /** |
michael@0 | 494 | * Sets the DST end rule to a fixed date within a month. |
michael@0 | 495 | * |
michael@0 | 496 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 497 | * @param dayOfMonth The date in that month (1-based). |
michael@0 | 498 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 499 | * when DST ends in local wall time, which is daylight |
michael@0 | 500 | * time in this case. |
michael@0 | 501 | * @param mode whether the time is local wall time, local standard time, |
michael@0 | 502 | * or UTC time. Default is local wall time. |
michael@0 | 503 | * @param status An UErrorCode |
michael@0 | 504 | * @stable ICU 2.0 |
michael@0 | 505 | */ |
michael@0 | 506 | void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, |
michael@0 | 507 | TimeMode mode, UErrorCode& status); |
michael@0 | 508 | |
michael@0 | 509 | /** |
michael@0 | 510 | * Sets the DST end rule to a weekday before or after a give date within |
michael@0 | 511 | * a month, e.g., the first Monday on or after the 8th. |
michael@0 | 512 | * |
michael@0 | 513 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 514 | * @param dayOfMonth A date within that month (1-based). |
michael@0 | 515 | * @param dayOfWeek The day of the week on which this rule occurs. |
michael@0 | 516 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 517 | * when DST ends in local wall time, which is daylight |
michael@0 | 518 | * time in this case. |
michael@0 | 519 | * @param after If true, this rule selects the first dayOfWeek on |
michael@0 | 520 | * or after dayOfMonth. If false, this rule selects |
michael@0 | 521 | * the last dayOfWeek on or before dayOfMonth. |
michael@0 | 522 | * @param status An UErrorCode |
michael@0 | 523 | * @stable ICU 2.0 |
michael@0 | 524 | */ |
michael@0 | 525 | void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, |
michael@0 | 526 | int32_t time, UBool after, UErrorCode& status); |
michael@0 | 527 | |
michael@0 | 528 | /** |
michael@0 | 529 | * Sets the DST end rule to a weekday before or after a give date within |
michael@0 | 530 | * a month, e.g., the first Monday on or after the 8th. |
michael@0 | 531 | * |
michael@0 | 532 | * @param month The month in which this rule occurs (0-based). |
michael@0 | 533 | * @param dayOfMonth A date within that month (1-based). |
michael@0 | 534 | * @param dayOfWeek The day of the week on which this rule occurs. |
michael@0 | 535 | * @param time The time of that day (number of millis after midnight) |
michael@0 | 536 | * when DST ends in local wall time, which is daylight |
michael@0 | 537 | * time in this case. |
michael@0 | 538 | * @param mode whether the time is local wall time, local standard time, |
michael@0 | 539 | * or UTC time. Default is local wall time. |
michael@0 | 540 | * @param after If true, this rule selects the first dayOfWeek on |
michael@0 | 541 | * or after dayOfMonth. If false, this rule selects |
michael@0 | 542 | * the last dayOfWeek on or before dayOfMonth. |
michael@0 | 543 | * @param status An UErrorCode |
michael@0 | 544 | * @stable ICU 2.0 |
michael@0 | 545 | */ |
michael@0 | 546 | void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, |
michael@0 | 547 | int32_t time, TimeMode mode, UBool after, UErrorCode& status); |
michael@0 | 548 | |
michael@0 | 549 | /** |
michael@0 | 550 | * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add |
michael@0 | 551 | * to GMT to get local time in this time zone, taking daylight savings time into |
michael@0 | 552 | * account) as of a particular reference date. The reference date is used to determine |
michael@0 | 553 | * whether daylight savings time is in effect and needs to be figured into the offset |
michael@0 | 554 | * that is returned (in other words, what is the adjusted GMT offset in this time zone |
michael@0 | 555 | * at this particular date and time?). For the time zones produced by createTimeZone(), |
michael@0 | 556 | * the reference data is specified according to the Gregorian calendar, and the date |
michael@0 | 557 | * and time fields are in GMT, NOT local time. |
michael@0 | 558 | * |
michael@0 | 559 | * @param era The reference date's era |
michael@0 | 560 | * @param year The reference date's year |
michael@0 | 561 | * @param month The reference date's month (0-based; 0 is January) |
michael@0 | 562 | * @param day The reference date's day-in-month (1-based) |
michael@0 | 563 | * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday) |
michael@0 | 564 | * @param millis The reference date's milliseconds in day, UTT (NOT local time). |
michael@0 | 565 | * @param status An UErrorCode to receive the status. |
michael@0 | 566 | * @return The offset in milliseconds to add to GMT to get local time. |
michael@0 | 567 | * @stable ICU 2.0 |
michael@0 | 568 | */ |
michael@0 | 569 | virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, |
michael@0 | 570 | uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const; |
michael@0 | 571 | |
michael@0 | 572 | /** |
michael@0 | 573 | * Gets the time zone offset, for current date, modified in case of |
michael@0 | 574 | * daylight savings. This is the offset to add *to* UTC to get local time. |
michael@0 | 575 | * @param era the era of the given date. |
michael@0 | 576 | * @param year the year in the given date. |
michael@0 | 577 | * @param month the month in the given date. |
michael@0 | 578 | * Month is 0-based. e.g., 0 for January. |
michael@0 | 579 | * @param day the day-in-month of the given date. |
michael@0 | 580 | * @param dayOfWeek the day-of-week of the given date. |
michael@0 | 581 | * @param milliseconds the millis in day in <em>standard</em> local time. |
michael@0 | 582 | * @param monthLength the length of the given month in days. |
michael@0 | 583 | * @param status An UErrorCode to receive the status. |
michael@0 | 584 | * @return the offset to add *to* GMT to get local time. |
michael@0 | 585 | * @stable ICU 2.0 |
michael@0 | 586 | */ |
michael@0 | 587 | virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, |
michael@0 | 588 | uint8_t dayOfWeek, int32_t milliseconds, |
michael@0 | 589 | int32_t monthLength, UErrorCode& status) const; |
michael@0 | 590 | /** |
michael@0 | 591 | * Gets the time zone offset, for current date, modified in case of |
michael@0 | 592 | * daylight savings. This is the offset to add *to* UTC to get local time. |
michael@0 | 593 | * @param era the era of the given date. |
michael@0 | 594 | * @param year the year in the given date. |
michael@0 | 595 | * @param month the month in the given date. |
michael@0 | 596 | * Month is 0-based. e.g., 0 for January. |
michael@0 | 597 | * @param day the day-in-month of the given date. |
michael@0 | 598 | * @param dayOfWeek the day-of-week of the given date. |
michael@0 | 599 | * @param milliseconds the millis in day in <em>standard</em> local time. |
michael@0 | 600 | * @param monthLength the length of the given month in days. |
michael@0 | 601 | * @param prevMonthLength length of the previous month in days. |
michael@0 | 602 | * @param status An UErrorCode to receive the status. |
michael@0 | 603 | * @return the offset to add *to* GMT to get local time. |
michael@0 | 604 | * @stable ICU 2.0 |
michael@0 | 605 | */ |
michael@0 | 606 | virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, |
michael@0 | 607 | uint8_t dayOfWeek, int32_t milliseconds, |
michael@0 | 608 | int32_t monthLength, int32_t prevMonthLength, |
michael@0 | 609 | UErrorCode& status) const; |
michael@0 | 610 | |
michael@0 | 611 | /** |
michael@0 | 612 | * Redeclared TimeZone method. This implementation simply calls |
michael@0 | 613 | * the base class method, which otherwise would be hidden. |
michael@0 | 614 | * @stable ICU 2.8 |
michael@0 | 615 | */ |
michael@0 | 616 | virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, |
michael@0 | 617 | int32_t& dstOffset, UErrorCode& ec) const; |
michael@0 | 618 | |
michael@0 | 619 | /** |
michael@0 | 620 | * Get time zone offsets from local wall time. |
michael@0 | 621 | * @internal |
michael@0 | 622 | */ |
michael@0 | 623 | virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt, |
michael@0 | 624 | int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const; |
michael@0 | 625 | |
michael@0 | 626 | /** |
michael@0 | 627 | * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add |
michael@0 | 628 | * to GMT to get local time, before taking daylight savings time into account). |
michael@0 | 629 | * |
michael@0 | 630 | * @return The TimeZone's raw GMT offset. |
michael@0 | 631 | * @stable ICU 2.0 |
michael@0 | 632 | */ |
michael@0 | 633 | virtual int32_t getRawOffset(void) const; |
michael@0 | 634 | |
michael@0 | 635 | /** |
michael@0 | 636 | * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add |
michael@0 | 637 | * to GMT to get local time, before taking daylight savings time into account). |
michael@0 | 638 | * |
michael@0 | 639 | * @param offsetMillis The new raw GMT offset for this time zone. |
michael@0 | 640 | * @stable ICU 2.0 |
michael@0 | 641 | */ |
michael@0 | 642 | virtual void setRawOffset(int32_t offsetMillis); |
michael@0 | 643 | |
michael@0 | 644 | /** |
michael@0 | 645 | * Sets the amount of time in ms that the clock is advanced during DST. |
michael@0 | 646 | * @param millisSavedDuringDST the number of milliseconds the time is |
michael@0 | 647 | * advanced with respect to standard time when the daylight savings rules |
michael@0 | 648 | * are in effect. A positive number, typically one hour (3600000). |
michael@0 | 649 | * @param status An UErrorCode to receive the status. |
michael@0 | 650 | * @stable ICU 2.0 |
michael@0 | 651 | */ |
michael@0 | 652 | void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status); |
michael@0 | 653 | |
michael@0 | 654 | /** |
michael@0 | 655 | * Returns the amount of time in ms that the clock is advanced during DST. |
michael@0 | 656 | * @return the number of milliseconds the time is |
michael@0 | 657 | * advanced with respect to standard time when the daylight savings rules |
michael@0 | 658 | * are in effect. A positive number, typically one hour (3600000). |
michael@0 | 659 | * @stable ICU 2.0 |
michael@0 | 660 | */ |
michael@0 | 661 | virtual int32_t getDSTSavings(void) const; |
michael@0 | 662 | |
michael@0 | 663 | /** |
michael@0 | 664 | * Queries if this TimeZone uses Daylight Savings Time. |
michael@0 | 665 | * |
michael@0 | 666 | * @return True if this TimeZone uses Daylight Savings Time; false otherwise. |
michael@0 | 667 | * @stable ICU 2.0 |
michael@0 | 668 | */ |
michael@0 | 669 | virtual UBool useDaylightTime(void) const; |
michael@0 | 670 | |
michael@0 | 671 | /** |
michael@0 | 672 | * Returns true if the given date is within the period when daylight savings time |
michael@0 | 673 | * is in effect; false otherwise. If the TimeZone doesn't observe daylight savings |
michael@0 | 674 | * time, this functions always returns false. |
michael@0 | 675 | * This method is wasteful since it creates a new GregorianCalendar and |
michael@0 | 676 | * deletes it each time it is called. This is a deprecated method |
michael@0 | 677 | * and provided only for Java compatibility. |
michael@0 | 678 | * |
michael@0 | 679 | * @param date The date to test. |
michael@0 | 680 | * @param status An UErrorCode to receive the status. |
michael@0 | 681 | * @return true if the given date is in Daylight Savings Time; |
michael@0 | 682 | * false otherwise. |
michael@0 | 683 | * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead. |
michael@0 | 684 | */ |
michael@0 | 685 | virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; |
michael@0 | 686 | |
michael@0 | 687 | /** |
michael@0 | 688 | * Return true if this zone has the same rules and offset as another zone. |
michael@0 | 689 | * @param other the TimeZone object to be compared with |
michael@0 | 690 | * @return true if the given zone has the same rules and offset as this one |
michael@0 | 691 | * @stable ICU 2.0 |
michael@0 | 692 | */ |
michael@0 | 693 | UBool hasSameRules(const TimeZone& other) const; |
michael@0 | 694 | |
michael@0 | 695 | /** |
michael@0 | 696 | * Clones TimeZone objects polymorphically. Clients are responsible for deleting |
michael@0 | 697 | * the TimeZone object cloned. |
michael@0 | 698 | * |
michael@0 | 699 | * @return A new copy of this TimeZone object. |
michael@0 | 700 | * @stable ICU 2.0 |
michael@0 | 701 | */ |
michael@0 | 702 | virtual TimeZone* clone(void) const; |
michael@0 | 703 | |
michael@0 | 704 | /** |
michael@0 | 705 | * Gets the first time zone transition after the base time. |
michael@0 | 706 | * @param base The base time. |
michael@0 | 707 | * @param inclusive Whether the base time is inclusive or not. |
michael@0 | 708 | * @param result Receives the first transition after the base time. |
michael@0 | 709 | * @return TRUE if the transition is found. |
michael@0 | 710 | * @stable ICU 3.8 |
michael@0 | 711 | */ |
michael@0 | 712 | virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const; |
michael@0 | 713 | |
michael@0 | 714 | /** |
michael@0 | 715 | * Gets the most recent time zone transition before the base time. |
michael@0 | 716 | * @param base The base time. |
michael@0 | 717 | * @param inclusive Whether the base time is inclusive or not. |
michael@0 | 718 | * @param result Receives the most recent transition before the base time. |
michael@0 | 719 | * @return TRUE if the transition is found. |
michael@0 | 720 | * @stable ICU 3.8 |
michael@0 | 721 | */ |
michael@0 | 722 | virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const; |
michael@0 | 723 | |
michael@0 | 724 | /** |
michael@0 | 725 | * Returns the number of <code>TimeZoneRule</code>s which represents time transitions, |
michael@0 | 726 | * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except |
michael@0 | 727 | * <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value. |
michael@0 | 728 | * @param status Receives error status code. |
michael@0 | 729 | * @return The number of <code>TimeZoneRule</code>s representing time transitions. |
michael@0 | 730 | * @stable ICU 3.8 |
michael@0 | 731 | */ |
michael@0 | 732 | virtual int32_t countTransitionRules(UErrorCode& status) const; |
michael@0 | 733 | |
michael@0 | 734 | /** |
michael@0 | 735 | * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code> |
michael@0 | 736 | * which represent time transitions for this time zone. On successful return, |
michael@0 | 737 | * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and |
michael@0 | 738 | * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code> |
michael@0 | 739 | * instances up to the size specified by trscount. The results are referencing the |
michael@0 | 740 | * rule instance held by this time zone instance. Therefore, after this time zone |
michael@0 | 741 | * is destructed, they are no longer available. |
michael@0 | 742 | * @param initial Receives the initial timezone rule |
michael@0 | 743 | * @param trsrules Receives the timezone transition rules |
michael@0 | 744 | * @param trscount On input, specify the size of the array 'transitions' receiving |
michael@0 | 745 | * the timezone transition rules. On output, actual number of |
michael@0 | 746 | * rules filled in the array will be set. |
michael@0 | 747 | * @param status Receives error status code. |
michael@0 | 748 | * @stable ICU 3.8 |
michael@0 | 749 | */ |
michael@0 | 750 | virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, |
michael@0 | 751 | const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const; |
michael@0 | 752 | |
michael@0 | 753 | |
michael@0 | 754 | public: |
michael@0 | 755 | |
michael@0 | 756 | /** |
michael@0 | 757 | * Override TimeZone Returns a unique class ID POLYMORPHICALLY. Pure virtual |
michael@0 | 758 | * override. This method is to implement a simple version of RTTI, since not all C++ |
michael@0 | 759 | * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call |
michael@0 | 760 | * this method. |
michael@0 | 761 | * |
michael@0 | 762 | * @return The class ID for this object. All objects of a given class have the |
michael@0 | 763 | * same class ID. Objects of other classes have different class IDs. |
michael@0 | 764 | * @stable ICU 2.0 |
michael@0 | 765 | */ |
michael@0 | 766 | virtual UClassID getDynamicClassID(void) const; |
michael@0 | 767 | |
michael@0 | 768 | /** |
michael@0 | 769 | * Return the class ID for this class. This is useful only for comparing to a return |
michael@0 | 770 | * value from getDynamicClassID(). For example: |
michael@0 | 771 | * <pre> |
michael@0 | 772 | * . Base* polymorphic_pointer = createPolymorphicObject(); |
michael@0 | 773 | * . if (polymorphic_pointer->getDynamicClassID() == |
michael@0 | 774 | * . Derived::getStaticClassID()) ... |
michael@0 | 775 | * </pre> |
michael@0 | 776 | * @return The class ID for all objects of this class. |
michael@0 | 777 | * @stable ICU 2.0 |
michael@0 | 778 | */ |
michael@0 | 779 | static UClassID U_EXPORT2 getStaticClassID(void); |
michael@0 | 780 | |
michael@0 | 781 | private: |
michael@0 | 782 | /** |
michael@0 | 783 | * Constants specifying values of startMode and endMode. |
michael@0 | 784 | */ |
michael@0 | 785 | enum EMode |
michael@0 | 786 | { |
michael@0 | 787 | DOM_MODE = 1, |
michael@0 | 788 | DOW_IN_MONTH_MODE, |
michael@0 | 789 | DOW_GE_DOM_MODE, |
michael@0 | 790 | DOW_LE_DOM_MODE |
michael@0 | 791 | }; |
michael@0 | 792 | |
michael@0 | 793 | SimpleTimeZone(); // default constructor not implemented |
michael@0 | 794 | |
michael@0 | 795 | /** |
michael@0 | 796 | * Internal construction method. |
michael@0 | 797 | * @param rawOffsetGMT The new SimpleTimeZone's raw GMT offset |
michael@0 | 798 | * @param startMonth the month DST starts |
michael@0 | 799 | * @param startDay the day DST starts |
michael@0 | 800 | * @param startDayOfWeek the DOW DST starts |
michael@0 | 801 | * @param startTime the time DST starts |
michael@0 | 802 | * @param startTimeMode Whether the start time is local wall time, local |
michael@0 | 803 | * standard time, or UTC time. Default is local wall time. |
michael@0 | 804 | * @param endMonth the month DST ends |
michael@0 | 805 | * @param endDay the day DST ends |
michael@0 | 806 | * @param endDayOfWeek the DOW DST ends |
michael@0 | 807 | * @param endTime the time DST ends |
michael@0 | 808 | * @param endTimeMode Whether the end time is local wall time, local |
michael@0 | 809 | * standard time, or UTC time. Default is local wall time. |
michael@0 | 810 | * @param dstSavings The number of milliseconds added to standard time |
michael@0 | 811 | * to get DST time. Default is one hour. |
michael@0 | 812 | * @param status An UErrorCode to receive the status. |
michael@0 | 813 | */ |
michael@0 | 814 | void construct(int32_t rawOffsetGMT, |
michael@0 | 815 | int8_t startMonth, int8_t startDay, int8_t startDayOfWeek, |
michael@0 | 816 | int32_t startTime, TimeMode startTimeMode, |
michael@0 | 817 | int8_t endMonth, int8_t endDay, int8_t endDayOfWeek, |
michael@0 | 818 | int32_t endTime, TimeMode endTimeMode, |
michael@0 | 819 | int32_t dstSavings, UErrorCode& status); |
michael@0 | 820 | |
michael@0 | 821 | /** |
michael@0 | 822 | * Compare a given date in the year to a rule. Return 1, 0, or -1, depending |
michael@0 | 823 | * on whether the date is after, equal to, or before the rule date. The |
michael@0 | 824 | * millis are compared directly against the ruleMillis, so any |
michael@0 | 825 | * standard-daylight adjustments must be handled by the caller. |
michael@0 | 826 | * |
michael@0 | 827 | * @return 1 if the date is after the rule date, -1 if the date is before |
michael@0 | 828 | * the rule date, or 0 if the date is equal to the rule date. |
michael@0 | 829 | */ |
michael@0 | 830 | static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen, |
michael@0 | 831 | int8_t dayOfMonth, |
michael@0 | 832 | int8_t dayOfWeek, int32_t millis, int32_t millisDelta, |
michael@0 | 833 | EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek, |
michael@0 | 834 | int8_t ruleDay, int32_t ruleMillis); |
michael@0 | 835 | |
michael@0 | 836 | /** |
michael@0 | 837 | * Given a set of encoded rules in startDay and startDayOfMonth, decode |
michael@0 | 838 | * them and set the startMode appropriately. Do the same for endDay and |
michael@0 | 839 | * endDayOfMonth. |
michael@0 | 840 | * <P> |
michael@0 | 841 | * Upon entry, the day of week variables may be zero or |
michael@0 | 842 | * negative, in order to indicate special modes. The day of month |
michael@0 | 843 | * variables may also be negative. |
michael@0 | 844 | * <P> |
michael@0 | 845 | * Upon exit, the mode variables will be |
michael@0 | 846 | * set, and the day of week and day of month variables will be positive. |
michael@0 | 847 | * <P> |
michael@0 | 848 | * This method also recognizes a startDay or endDay of zero as indicating |
michael@0 | 849 | * no DST. |
michael@0 | 850 | */ |
michael@0 | 851 | void decodeRules(UErrorCode& status); |
michael@0 | 852 | void decodeStartRule(UErrorCode& status); |
michael@0 | 853 | void decodeEndRule(UErrorCode& status); |
michael@0 | 854 | |
michael@0 | 855 | int8_t startMonth, startDay, startDayOfWeek; // the month, day, DOW, and time DST starts |
michael@0 | 856 | int32_t startTime; |
michael@0 | 857 | TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode |
michael@0 | 858 | int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends |
michael@0 | 859 | int32_t endTime; |
michael@0 | 860 | int32_t startYear; // the year these DST rules took effect |
michael@0 | 861 | int32_t rawOffset; // the TimeZone's raw GMT offset |
michael@0 | 862 | UBool useDaylight; // flag indicating whether this TimeZone uses DST |
michael@0 | 863 | static const int8_t STATICMONTHLENGTH[12]; // lengths of the months |
michael@0 | 864 | EMode startMode, endMode; // flags indicating what kind of rules the DST rules are |
michael@0 | 865 | |
michael@0 | 866 | /** |
michael@0 | 867 | * A positive value indicating the amount of time saved during DST in ms. |
michael@0 | 868 | * Typically one hour; sometimes 30 minutes. |
michael@0 | 869 | */ |
michael@0 | 870 | int32_t dstSavings; |
michael@0 | 871 | |
michael@0 | 872 | /* Private for BasicTimeZone implementation */ |
michael@0 | 873 | void checkTransitionRules(UErrorCode& status) const; |
michael@0 | 874 | void initTransitionRules(UErrorCode& status); |
michael@0 | 875 | void clearTransitionRules(void); |
michael@0 | 876 | void deleteTransitionRules(void); |
michael@0 | 877 | UBool transitionRulesInitialized; |
michael@0 | 878 | InitialTimeZoneRule* initialRule; |
michael@0 | 879 | TimeZoneTransition* firstTransition; |
michael@0 | 880 | AnnualTimeZoneRule* stdRule; |
michael@0 | 881 | AnnualTimeZoneRule* dstRule; |
michael@0 | 882 | }; |
michael@0 | 883 | |
michael@0 | 884 | inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth, |
michael@0 | 885 | int32_t dayOfWeek, |
michael@0 | 886 | int32_t time, UErrorCode& status) { |
michael@0 | 887 | setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status); |
michael@0 | 888 | } |
michael@0 | 889 | |
michael@0 | 890 | inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, |
michael@0 | 891 | int32_t time, |
michael@0 | 892 | UErrorCode& status) { |
michael@0 | 893 | setStartRule(month, dayOfMonth, time, WALL_TIME, status); |
michael@0 | 894 | } |
michael@0 | 895 | |
michael@0 | 896 | inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, |
michael@0 | 897 | int32_t dayOfWeek, |
michael@0 | 898 | int32_t time, UBool after, UErrorCode& status) { |
michael@0 | 899 | setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status); |
michael@0 | 900 | } |
michael@0 | 901 | |
michael@0 | 902 | inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth, |
michael@0 | 903 | int32_t dayOfWeek, |
michael@0 | 904 | int32_t time, UErrorCode& status) { |
michael@0 | 905 | setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status); |
michael@0 | 906 | } |
michael@0 | 907 | |
michael@0 | 908 | inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, |
michael@0 | 909 | int32_t time, UErrorCode& status) { |
michael@0 | 910 | setEndRule(month, dayOfMonth, time, WALL_TIME, status); |
michael@0 | 911 | } |
michael@0 | 912 | |
michael@0 | 913 | inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, |
michael@0 | 914 | int32_t time, UBool after, UErrorCode& status) { |
michael@0 | 915 | setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status); |
michael@0 | 916 | } |
michael@0 | 917 | |
michael@0 | 918 | inline void |
michael@0 | 919 | SimpleTimeZone::getOffset(UDate date, UBool local, int32_t& rawOffsetRef, |
michael@0 | 920 | int32_t& dstOffsetRef, UErrorCode& ec) const { |
michael@0 | 921 | TimeZone::getOffset(date, local, rawOffsetRef, dstOffsetRef, ec); |
michael@0 | 922 | } |
michael@0 | 923 | |
michael@0 | 924 | U_NAMESPACE_END |
michael@0 | 925 | |
michael@0 | 926 | #endif /* #if !UCONFIG_NO_FORMATTING */ |
michael@0 | 927 | |
michael@0 | 928 | #endif // _SIMPLETZ |