annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/simpletz.h @ 69:33d812a61356

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