annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/timezone.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 * Copyright (c) 1997-2016, International Business Machines Corporation
jpayne@69 5 * and others. All Rights Reserved.
jpayne@69 6 **************************************************************************
jpayne@69 7 *
jpayne@69 8 * File TIMEZONE.H
jpayne@69 9 *
jpayne@69 10 * Modification History:
jpayne@69 11 *
jpayne@69 12 * Date Name Description
jpayne@69 13 * 04/21/97 aliu Overhauled header.
jpayne@69 14 * 07/09/97 helena Changed createInstance to createDefault.
jpayne@69 15 * 08/06/97 aliu Removed dependency on internal header for Hashtable.
jpayne@69 16 * 08/10/98 stephen Changed getDisplayName() API conventions to match
jpayne@69 17 * 08/19/98 stephen Changed createTimeZone() to never return 0
jpayne@69 18 * 09/02/98 stephen Sync to JDK 1.2 8/31
jpayne@69 19 * - Added getOffset(... monthlen ...)
jpayne@69 20 * - Added hasSameRules()
jpayne@69 21 * 09/15/98 stephen Added getStaticClassID
jpayne@69 22 * 12/03/99 aliu Moved data out of static table into icudata.dll.
jpayne@69 23 * Hashtable replaced by new static data structures.
jpayne@69 24 * 12/14/99 aliu Made GMT public.
jpayne@69 25 * 08/15/01 grhoten Made GMT private and added the getGMT() function
jpayne@69 26 **************************************************************************
jpayne@69 27 */
jpayne@69 28
jpayne@69 29 #ifndef TIMEZONE_H
jpayne@69 30 #define TIMEZONE_H
jpayne@69 31
jpayne@69 32 #include "unicode/utypes.h"
jpayne@69 33
jpayne@69 34 #if U_SHOW_CPLUSPLUS_API
jpayne@69 35
jpayne@69 36 /**
jpayne@69 37 * \file
jpayne@69 38 * \brief C++ API: TimeZone object
jpayne@69 39 */
jpayne@69 40
jpayne@69 41 #if !UCONFIG_NO_FORMATTING
jpayne@69 42
jpayne@69 43 #include "unicode/uobject.h"
jpayne@69 44 #include "unicode/unistr.h"
jpayne@69 45 #include "unicode/ures.h"
jpayne@69 46 #include "unicode/ucal.h"
jpayne@69 47
jpayne@69 48 U_NAMESPACE_BEGIN
jpayne@69 49
jpayne@69 50 class StringEnumeration;
jpayne@69 51
jpayne@69 52 /**
jpayne@69 53 *
jpayne@69 54 * <code>TimeZone</code> represents a time zone offset, and also figures out daylight
jpayne@69 55 * savings.
jpayne@69 56 *
jpayne@69 57 * <p>
jpayne@69 58 * Typically, you get a <code>TimeZone</code> using <code>createDefault</code>
jpayne@69 59 * which creates a <code>TimeZone</code> based on the time zone where the program
jpayne@69 60 * is running. For example, for a program running in Japan, <code>createDefault</code>
jpayne@69 61 * creates a <code>TimeZone</code> object based on Japanese Standard Time.
jpayne@69 62 *
jpayne@69 63 * <p>
jpayne@69 64 * You can also get a <code>TimeZone</code> using <code>createTimeZone</code> along
jpayne@69 65 * with a time zone ID. For instance, the time zone ID for the US Pacific
jpayne@69 66 * Time zone is "America/Los_Angeles". So, you can get a Pacific Time <code>TimeZone</code> object
jpayne@69 67 * with:
jpayne@69 68 * \htmlonly<blockquote>\endhtmlonly
jpayne@69 69 * <pre>
jpayne@69 70 * TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles");
jpayne@69 71 * </pre>
jpayne@69 72 * \htmlonly</blockquote>\endhtmlonly
jpayne@69 73 * You can use the <code>createEnumeration</code> method to iterate through
jpayne@69 74 * all the supported time zone IDs, or the <code>getCanonicalID</code> method to check
jpayne@69 75 * if a time zone ID is supported or not. You can then choose a
jpayne@69 76 * supported ID to get a <code>TimeZone</code>.
jpayne@69 77 * If the time zone you want is not represented by one of the
jpayne@69 78 * supported IDs, then you can create a custom time zone ID with
jpayne@69 79 * the following syntax:
jpayne@69 80 *
jpayne@69 81 * \htmlonly<blockquote>\endhtmlonly
jpayne@69 82 * <pre>
jpayne@69 83 * GMT[+|-]hh[[:]mm]
jpayne@69 84 * </pre>
jpayne@69 85 * \htmlonly</blockquote>\endhtmlonly
jpayne@69 86 *
jpayne@69 87 * For example, you might specify GMT+14:00 as a custom
jpayne@69 88 * time zone ID. The <code>TimeZone</code> that is returned
jpayne@69 89 * when you specify a custom time zone ID uses the specified
jpayne@69 90 * offset from GMT(=UTC) and does not observe daylight saving
jpayne@69 91 * time. For example, you might specify GMT+14:00 as a custom
jpayne@69 92 * time zone ID to create a TimeZone representing 14 hours ahead
jpayne@69 93 * of GMT (with no daylight saving time). In addition,
jpayne@69 94 * <code>getCanonicalID</code> can also be used to
jpayne@69 95 * normalize a custom time zone ID.
jpayne@69 96 *
jpayne@69 97 * TimeZone is an abstract class representing a time zone. A TimeZone is needed for
jpayne@69 98 * Calendar to produce local time for a particular time zone. A TimeZone comprises
jpayne@69 99 * three basic pieces of information:
jpayne@69 100 * <ul>
jpayne@69 101 * <li>A time zone offset; that, is the number of milliseconds to add or subtract
jpayne@69 102 * from a time expressed in terms of GMT to convert it to the same time in that
jpayne@69 103 * time zone (without taking daylight savings time into account).</li>
jpayne@69 104 * <li>Logic necessary to take daylight savings time into account if daylight savings
jpayne@69 105 * time is observed in that time zone (e.g., the days and hours on which daylight
jpayne@69 106 * savings time begins and ends).</li>
jpayne@69 107 * <li>An ID. This is a text string that uniquely identifies the time zone.</li>
jpayne@69 108 * </ul>
jpayne@69 109 *
jpayne@69 110 * (Only the ID is actually implemented in TimeZone; subclasses of TimeZone may handle
jpayne@69 111 * daylight savings time and GMT offset in different ways. Currently we have the following
jpayne@69 112 * TimeZone subclasses: RuleBasedTimeZone, SimpleTimeZone, and VTimeZone.)
jpayne@69 113 * <P>
jpayne@69 114 * The TimeZone class contains a static list containing a TimeZone object for every
jpayne@69 115 * combination of GMT offset and daylight-savings time rules currently in use in the
jpayne@69 116 * world, each with a unique ID. Each ID consists of a region (usually a continent or
jpayne@69 117 * ocean) and a city in that region, separated by a slash, (for example, US Pacific
jpayne@69 118 * Time is "America/Los_Angeles.") Because older versions of this class used
jpayne@69 119 * three- or four-letter abbreviations instead, there is also a table that maps the older
jpayne@69 120 * abbreviations to the newer ones (for example, "PST" maps to "America/Los_Angeles").
jpayne@69 121 * Anywhere the API requires an ID, you can use either form.
jpayne@69 122 * <P>
jpayne@69 123 * To create a new TimeZone, you call the factory function TimeZone::createTimeZone()
jpayne@69 124 * and pass it a time zone ID. You can use the createEnumeration() function to
jpayne@69 125 * obtain a list of all the time zone IDs recognized by createTimeZone().
jpayne@69 126 * <P>
jpayne@69 127 * You can also use TimeZone::createDefault() to create a TimeZone. This function uses
jpayne@69 128 * platform-specific APIs to produce a TimeZone for the time zone corresponding to
jpayne@69 129 * the client's computer's physical location. For example, if you're in Japan (assuming
jpayne@69 130 * your machine is set up correctly), TimeZone::createDefault() will return a TimeZone
jpayne@69 131 * for Japanese Standard Time ("Asia/Tokyo").
jpayne@69 132 */
jpayne@69 133 class U_I18N_API TimeZone : public UObject {
jpayne@69 134 public:
jpayne@69 135 /**
jpayne@69 136 * @stable ICU 2.0
jpayne@69 137 */
jpayne@69 138 virtual ~TimeZone();
jpayne@69 139
jpayne@69 140 /**
jpayne@69 141 * Returns the "unknown" time zone.
jpayne@69 142 * It behaves like the GMT/UTC time zone but has the
jpayne@69 143 * <code>UCAL_UNKNOWN_ZONE_ID</code> = "Etc/Unknown".
jpayne@69 144 * createTimeZone() returns a mutable clone of this time zone if the input ID is not recognized.
jpayne@69 145 *
jpayne@69 146 * @return the "unknown" time zone.
jpayne@69 147 * @see UCAL_UNKNOWN_ZONE_ID
jpayne@69 148 * @see createTimeZone
jpayne@69 149 * @see getGMT
jpayne@69 150 * @stable ICU 49
jpayne@69 151 */
jpayne@69 152 static const TimeZone& U_EXPORT2 getUnknown();
jpayne@69 153
jpayne@69 154 /**
jpayne@69 155 * The GMT (=UTC) time zone has a raw offset of zero and does not use daylight
jpayne@69 156 * savings time. This is a commonly used time zone.
jpayne@69 157 *
jpayne@69 158 * <p>Note: For backward compatibility reason, the ID used by the time
jpayne@69 159 * zone returned by this method is "GMT", although the ICU's canonical
jpayne@69 160 * ID for the GMT time zone is "Etc/GMT".
jpayne@69 161 *
jpayne@69 162 * @return the GMT/UTC time zone.
jpayne@69 163 * @see getUnknown
jpayne@69 164 * @stable ICU 2.0
jpayne@69 165 */
jpayne@69 166 static const TimeZone* U_EXPORT2 getGMT(void);
jpayne@69 167
jpayne@69 168 /**
jpayne@69 169 * Creates a <code>TimeZone</code> for the given ID.
jpayne@69 170 * @param ID the ID for a <code>TimeZone</code>, such as "America/Los_Angeles",
jpayne@69 171 * or a custom ID such as "GMT-8:00".
jpayne@69 172 * @return the specified <code>TimeZone</code>, or a mutable clone of getUnknown()
jpayne@69 173 * if the given ID cannot be understood or if the given ID is "Etc/Unknown".
jpayne@69 174 * The return result is guaranteed to be non-NULL.
jpayne@69 175 * If you require that the specific zone asked for be returned,
jpayne@69 176 * compare the result with getUnknown() or check the ID of the return result.
jpayne@69 177 * @stable ICU 2.0
jpayne@69 178 */
jpayne@69 179 static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);
jpayne@69 180
jpayne@69 181 /**
jpayne@69 182 * Returns an enumeration over system time zone IDs with the given
jpayne@69 183 * filter conditions.
jpayne@69 184 * @param zoneType The system time zone type.
jpayne@69 185 * @param region The ISO 3166 two-letter country code or UN M.49
jpayne@69 186 * three-digit area code. When NULL, no filtering
jpayne@69 187 * done by region.
jpayne@69 188 * @param rawOffset An offset from GMT in milliseconds, ignoring
jpayne@69 189 * the effect of daylight savings time, if any.
jpayne@69 190 * When NULL, no filtering done by zone offset.
jpayne@69 191 * @param ec Output param to filled in with a success or
jpayne@69 192 * an error.
jpayne@69 193 * @return an enumeration object, owned by the caller.
jpayne@69 194 * @stable ICU 4.8
jpayne@69 195 */
jpayne@69 196 static StringEnumeration* U_EXPORT2 createTimeZoneIDEnumeration(
jpayne@69 197 USystemTimeZoneType zoneType,
jpayne@69 198 const char* region,
jpayne@69 199 const int32_t* rawOffset,
jpayne@69 200 UErrorCode& ec);
jpayne@69 201
jpayne@69 202 /**
jpayne@69 203 * Returns an enumeration over all recognized time zone IDs. (i.e.,
jpayne@69 204 * all strings that createTimeZone() accepts)
jpayne@69 205 *
jpayne@69 206 * @return an enumeration object, owned by the caller.
jpayne@69 207 * @stable ICU 2.4
jpayne@69 208 */
jpayne@69 209 static StringEnumeration* U_EXPORT2 createEnumeration();
jpayne@69 210
jpayne@69 211 /**
jpayne@69 212 * Returns an enumeration over time zone IDs with a given raw
jpayne@69 213 * offset from GMT. There may be several times zones with the
jpayne@69 214 * same GMT offset that differ in the way they handle daylight
jpayne@69 215 * savings time. For example, the state of Arizona doesn't
jpayne@69 216 * observe daylight savings time. If you ask for the time zone
jpayne@69 217 * IDs corresponding to GMT-7:00, you'll get back an enumeration
jpayne@69 218 * over two time zone IDs: "America/Denver," which corresponds to
jpayne@69 219 * Mountain Standard Time in the winter and Mountain Daylight Time
jpayne@69 220 * in the summer, and "America/Phoenix", which corresponds to
jpayne@69 221 * Mountain Standard Time year-round, even in the summer.
jpayne@69 222 *
jpayne@69 223 * @param rawOffset an offset from GMT in milliseconds, ignoring
jpayne@69 224 * the effect of daylight savings time, if any
jpayne@69 225 * @return an enumeration object, owned by the caller
jpayne@69 226 * @stable ICU 2.4
jpayne@69 227 */
jpayne@69 228 static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);
jpayne@69 229
jpayne@69 230 /**
jpayne@69 231 * Returns an enumeration over time zone IDs associated with the
jpayne@69 232 * given country. Some zones are affiliated with no country
jpayne@69 233 * (e.g., "UTC"); these may also be retrieved, as a group.
jpayne@69 234 *
jpayne@69 235 * @param country The ISO 3166 two-letter country code, or NULL to
jpayne@69 236 * retrieve zones not affiliated with any country.
jpayne@69 237 * @return an enumeration object, owned by the caller
jpayne@69 238 * @stable ICU 2.4
jpayne@69 239 */
jpayne@69 240 static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);
jpayne@69 241
jpayne@69 242 /**
jpayne@69 243 * Returns the number of IDs in the equivalency group that
jpayne@69 244 * includes the given ID. An equivalency group contains zones
jpayne@69 245 * that have the same GMT offset and rules.
jpayne@69 246 *
jpayne@69 247 * <p>The returned count includes the given ID; it is always >= 1.
jpayne@69 248 * The given ID must be a system time zone. If it is not, returns
jpayne@69 249 * zero.
jpayne@69 250 * @param id a system time zone ID
jpayne@69 251 * @return the number of zones in the equivalency group containing
jpayne@69 252 * 'id', or zero if 'id' is not a valid system ID
jpayne@69 253 * @see #getEquivalentID
jpayne@69 254 * @stable ICU 2.0
jpayne@69 255 */
jpayne@69 256 static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);
jpayne@69 257
jpayne@69 258 /**
jpayne@69 259 * Returns an ID in the equivalency group that
jpayne@69 260 * includes the given ID. An equivalency group contains zones
jpayne@69 261 * that have the same GMT offset and rules.
jpayne@69 262 *
jpayne@69 263 * <p>The given index must be in the range 0..n-1, where n is the
jpayne@69 264 * value returned by <code>countEquivalentIDs(id)</code>. For
jpayne@69 265 * some value of 'index', the returned value will be equal to the
jpayne@69 266 * given id. If the given id is not a valid system time zone, or
jpayne@69 267 * if 'index' is out of range, then returns an empty string.
jpayne@69 268 * @param id a system time zone ID
jpayne@69 269 * @param index a value from 0 to n-1, where n is the value
jpayne@69 270 * returned by <code>countEquivalentIDs(id)</code>
jpayne@69 271 * @return the ID of the index-th zone in the equivalency group
jpayne@69 272 * containing 'id', or an empty string if 'id' is not a valid
jpayne@69 273 * system ID or 'index' is out of range
jpayne@69 274 * @see #countEquivalentIDs
jpayne@69 275 * @stable ICU 2.0
jpayne@69 276 */
jpayne@69 277 static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,
jpayne@69 278 int32_t index);
jpayne@69 279
jpayne@69 280 /**
jpayne@69 281 * Creates an instance of TimeZone detected from the current host
jpayne@69 282 * system configuration. If the host system detection routines fail,
jpayne@69 283 * or if they specify a TimeZone or TimeZone offset which is not
jpayne@69 284 * recognized, then the special TimeZone "Etc/Unknown" is returned.
jpayne@69 285 *
jpayne@69 286 * Note that ICU4C does not change the default time zone unless
jpayne@69 287 * `TimeZone::adoptDefault(TimeZone*)` or
jpayne@69 288 * `TimeZone::setDefault(const TimeZone&)` is explicitly called by a
jpayne@69 289 * user. This method does not update the current ICU's default,
jpayne@69 290 * and may return a different TimeZone from the one returned by
jpayne@69 291 * `TimeZone::createDefault()`.
jpayne@69 292 *
jpayne@69 293 * <p>This function is not thread safe.</p>
jpayne@69 294 *
jpayne@69 295 * @return A new instance of TimeZone detected from the current host system
jpayne@69 296 * configuration.
jpayne@69 297 * @see adoptDefault
jpayne@69 298 * @see setDefault
jpayne@69 299 * @see createDefault
jpayne@69 300 * @see getUnknown
jpayne@69 301 * @stable ICU 55
jpayne@69 302 */
jpayne@69 303 static TimeZone* U_EXPORT2 detectHostTimeZone();
jpayne@69 304
jpayne@69 305 /**
jpayne@69 306 * Creates a new copy of the default TimeZone for this host. Unless the default time
jpayne@69 307 * zone has already been set using adoptDefault() or setDefault(), the default is
jpayne@69 308 * determined by querying the host system configuration. If the host system detection
jpayne@69 309 * routines fail, or if they specify a TimeZone or TimeZone offset which is not
jpayne@69 310 * recognized, then the special TimeZone "Etc/Unknown" is instantiated and made the
jpayne@69 311 * default.
jpayne@69 312 *
jpayne@69 313 * @return A default TimeZone. Clients are responsible for deleting the time zone
jpayne@69 314 * object returned.
jpayne@69 315 * @see getUnknown
jpayne@69 316 * @stable ICU 2.0
jpayne@69 317 */
jpayne@69 318 static TimeZone* U_EXPORT2 createDefault(void);
jpayne@69 319
jpayne@69 320 /**
jpayne@69 321 * Sets the default time zone (i.e., what's returned by createDefault()) to be the
jpayne@69 322 * specified time zone. If NULL is specified for the time zone, the default time
jpayne@69 323 * zone is set to the default host time zone. This call adopts the TimeZone object
jpayne@69 324 * passed in; the client is no longer responsible for deleting it.
jpayne@69 325 *
jpayne@69 326 * @param zone A pointer to the new TimeZone object to use as the default.
jpayne@69 327 * @stable ICU 2.0
jpayne@69 328 */
jpayne@69 329 static void U_EXPORT2 adoptDefault(TimeZone* zone);
jpayne@69 330
jpayne@69 331 #ifndef U_HIDE_SYSTEM_API
jpayne@69 332 /**
jpayne@69 333 * Same as adoptDefault(), except that the TimeZone object passed in is NOT adopted;
jpayne@69 334 * the caller remains responsible for deleting it.
jpayne@69 335 *
jpayne@69 336 * @param zone The given timezone.
jpayne@69 337 * @system
jpayne@69 338 * @stable ICU 2.0
jpayne@69 339 */
jpayne@69 340 static void U_EXPORT2 setDefault(const TimeZone& zone);
jpayne@69 341 #endif /* U_HIDE_SYSTEM_API */
jpayne@69 342
jpayne@69 343 /**
jpayne@69 344 * Returns the timezone data version currently used by ICU.
jpayne@69 345 * @param status Output param to filled in with a success or an error.
jpayne@69 346 * @return the version string, such as "2007f"
jpayne@69 347 * @stable ICU 3.8
jpayne@69 348 */
jpayne@69 349 static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status);
jpayne@69 350
jpayne@69 351 /**
jpayne@69 352 * Returns the canonical system timezone ID or the normalized
jpayne@69 353 * custom time zone ID for the given time zone ID.
jpayne@69 354 * @param id The input time zone ID to be canonicalized.
jpayne@69 355 * @param canonicalID Receives the canonical system time zone ID
jpayne@69 356 * or the custom time zone ID in normalized format.
jpayne@69 357 * @param status Receives the status. When the given time zone ID
jpayne@69 358 * is neither a known system time zone ID nor a
jpayne@69 359 * valid custom time zone ID, U_ILLEGAL_ARGUMENT_ERROR
jpayne@69 360 * is set.
jpayne@69 361 * @return A reference to the result.
jpayne@69 362 * @stable ICU 4.0
jpayne@69 363 */
jpayne@69 364 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
jpayne@69 365 UnicodeString& canonicalID, UErrorCode& status);
jpayne@69 366
jpayne@69 367 /**
jpayne@69 368 * Returns the canonical system time zone ID or the normalized
jpayne@69 369 * custom time zone ID for the given time zone ID.
jpayne@69 370 * @param id The input time zone ID to be canonicalized.
jpayne@69 371 * @param canonicalID Receives the canonical system time zone ID
jpayne@69 372 * or the custom time zone ID in normalized format.
jpayne@69 373 * @param isSystemID Receives if the given ID is a known system
jpayne@69 374 * time zone ID.
jpayne@69 375 * @param status Receives the status. When the given time zone ID
jpayne@69 376 * is neither a known system time zone ID nor a
jpayne@69 377 * valid custom time zone ID, U_ILLEGAL_ARGUMENT_ERROR
jpayne@69 378 * is set.
jpayne@69 379 * @return A reference to the result.
jpayne@69 380 * @stable ICU 4.0
jpayne@69 381 */
jpayne@69 382 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
jpayne@69 383 UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status);
jpayne@69 384
jpayne@69 385 /**
jpayne@69 386 * Converts a system time zone ID to an equivalent Windows time zone ID. For example,
jpayne@69 387 * Windows time zone ID "Pacific Standard Time" is returned for input "America/Los_Angeles".
jpayne@69 388 *
jpayne@69 389 * <p>There are system time zones that cannot be mapped to Windows zones. When the input
jpayne@69 390 * system time zone ID is unknown or unmappable to a Windows time zone, then the result will be
jpayne@69 391 * empty, but the operation itself remains successful (no error status set on return).
jpayne@69 392 *
jpayne@69 393 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
jpayne@69 394 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
jpayne@69 395 * please read the ICU user guide section <a href="http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data">
jpayne@69 396 * Updating the Time Zone Data</a>.
jpayne@69 397 *
jpayne@69 398 * @param id A system time zone ID.
jpayne@69 399 * @param winid Receives a Windows time zone ID. When the input system time zone ID is unknown
jpayne@69 400 * or unmappable to a Windows time zone ID, then an empty string is set on return.
jpayne@69 401 * @param status Receives the status.
jpayne@69 402 * @return A reference to the result (<code>winid</code>).
jpayne@69 403 * @see getIDForWindowsID
jpayne@69 404 *
jpayne@69 405 * @stable ICU 52
jpayne@69 406 */
jpayne@69 407 static UnicodeString& U_EXPORT2 getWindowsID(const UnicodeString& id,
jpayne@69 408 UnicodeString& winid, UErrorCode& status);
jpayne@69 409
jpayne@69 410 /**
jpayne@69 411 * Converts a Windows time zone ID to an equivalent system time zone ID
jpayne@69 412 * for a region. For example, system time zone ID "America/Los_Angeles" is returned
jpayne@69 413 * for input Windows ID "Pacific Standard Time" and region "US" (or <code>null</code>),
jpayne@69 414 * "America/Vancouver" is returned for the same Windows ID "Pacific Standard Time" and
jpayne@69 415 * region "CA".
jpayne@69 416 *
jpayne@69 417 * <p>Not all Windows time zones can be mapped to system time zones. When the input
jpayne@69 418 * Windows time zone ID is unknown or unmappable to a system time zone, then the result
jpayne@69 419 * will be empty, but the operation itself remains successful (no error status set on return).
jpayne@69 420 *
jpayne@69 421 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
jpayne@69 422 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
jpayne@69 423 * please read the ICU user guide section <a href="http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data">
jpayne@69 424 * Updating the Time Zone Data</a>.
jpayne@69 425 *
jpayne@69 426 * @param winid A Windows time zone ID.
jpayne@69 427 * @param region A null-terminated region code, or <code>NULL</code> if no regional preference.
jpayne@69 428 * @param id Receives a system time zone ID. When the input Windows time zone ID is unknown
jpayne@69 429 * or unmappable to a system time zone ID, then an empty string is set on return.
jpayne@69 430 * @param status Receives the status.
jpayne@69 431 * @return A reference to the result (<code>id</code>).
jpayne@69 432 * @see getWindowsID
jpayne@69 433 *
jpayne@69 434 * @stable ICU 52
jpayne@69 435 */
jpayne@69 436 static UnicodeString& U_EXPORT2 getIDForWindowsID(const UnicodeString& winid, const char* region,
jpayne@69 437 UnicodeString& id, UErrorCode& status);
jpayne@69 438
jpayne@69 439 /**
jpayne@69 440 * Returns true if the two TimeZones are equal. (The TimeZone version only compares
jpayne@69 441 * IDs, but subclasses are expected to also compare the fields they add.)
jpayne@69 442 *
jpayne@69 443 * @param that The TimeZone object to be compared with.
jpayne@69 444 * @return True if the given TimeZone is equal to this TimeZone; false
jpayne@69 445 * otherwise.
jpayne@69 446 * @stable ICU 2.0
jpayne@69 447 */
jpayne@69 448 virtual UBool operator==(const TimeZone& that) const;
jpayne@69 449
jpayne@69 450 /**
jpayne@69 451 * Returns true if the two TimeZones are NOT equal; that is, if operator==() returns
jpayne@69 452 * false.
jpayne@69 453 *
jpayne@69 454 * @param that The TimeZone object to be compared with.
jpayne@69 455 * @return True if the given TimeZone is not equal to this TimeZone; false
jpayne@69 456 * otherwise.
jpayne@69 457 * @stable ICU 2.0
jpayne@69 458 */
jpayne@69 459 UBool operator!=(const TimeZone& that) const {return !operator==(that);}
jpayne@69 460
jpayne@69 461 /**
jpayne@69 462 * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
jpayne@69 463 * to GMT to get local time in this time zone, taking daylight savings time into
jpayne@69 464 * account) as of a particular reference date. The reference date is used to determine
jpayne@69 465 * whether daylight savings time is in effect and needs to be figured into the offset
jpayne@69 466 * that is returned (in other words, what is the adjusted GMT offset in this time zone
jpayne@69 467 * at this particular date and time?). For the time zones produced by createTimeZone(),
jpayne@69 468 * the reference data is specified according to the Gregorian calendar, and the date
jpayne@69 469 * and time fields are local standard time.
jpayne@69 470 *
jpayne@69 471 * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
jpayne@69 472 * which returns both the raw and the DST offset for a given time. This method
jpayne@69 473 * is retained only for backward compatibility.
jpayne@69 474 *
jpayne@69 475 * @param era The reference date's era
jpayne@69 476 * @param year The reference date's year
jpayne@69 477 * @param month The reference date's month (0-based; 0 is January)
jpayne@69 478 * @param day The reference date's day-in-month (1-based)
jpayne@69 479 * @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
jpayne@69 480 * @param millis The reference date's milliseconds in day, local standard time
jpayne@69 481 * @param status Output param to filled in with a success or an error.
jpayne@69 482 * @return The offset in milliseconds to add to GMT to get local time.
jpayne@69 483 * @stable ICU 2.0
jpayne@69 484 */
jpayne@69 485 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
jpayne@69 486 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
jpayne@69 487
jpayne@69 488 /**
jpayne@69 489 * Gets the time zone offset, for current date, modified in case of
jpayne@69 490 * daylight savings. This is the offset to add *to* UTC to get local time.
jpayne@69 491 *
jpayne@69 492 * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
jpayne@69 493 * which returns both the raw and the DST offset for a given time. This method
jpayne@69 494 * is retained only for backward compatibility.
jpayne@69 495 *
jpayne@69 496 * @param era the era of the given date.
jpayne@69 497 * @param year the year in the given date.
jpayne@69 498 * @param month the month in the given date.
jpayne@69 499 * Month is 0-based. e.g., 0 for January.
jpayne@69 500 * @param day the day-in-month of the given date.
jpayne@69 501 * @param dayOfWeek the day-of-week of the given date.
jpayne@69 502 * @param milliseconds the millis in day in <em>standard</em> local time.
jpayne@69 503 * @param monthLength the length of the given month in days.
jpayne@69 504 * @param status Output param to filled in with a success or an error.
jpayne@69 505 * @return the offset to add *to* GMT to get local time.
jpayne@69 506 * @stable ICU 2.0
jpayne@69 507 */
jpayne@69 508 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
jpayne@69 509 uint8_t dayOfWeek, int32_t milliseconds,
jpayne@69 510 int32_t monthLength, UErrorCode& status) const = 0;
jpayne@69 511
jpayne@69 512 /**
jpayne@69 513 * Returns the time zone raw and GMT offset for the given moment
jpayne@69 514 * in time. Upon return, local-millis = GMT-millis + rawOffset +
jpayne@69 515 * dstOffset. All computations are performed in the proleptic
jpayne@69 516 * Gregorian calendar. The default implementation in the TimeZone
jpayne@69 517 * class delegates to the 8-argument getOffset().
jpayne@69 518 *
jpayne@69 519 * @param date moment in time for which to return offsets, in
jpayne@69 520 * units of milliseconds from January 1, 1970 0:00 GMT, either GMT
jpayne@69 521 * time or local wall time, depending on `local'.
jpayne@69 522 * @param local if true, `date' is local wall time; otherwise it
jpayne@69 523 * is in GMT time.
jpayne@69 524 * @param rawOffset output parameter to receive the raw offset, that
jpayne@69 525 * is, the offset not including DST adjustments
jpayne@69 526 * @param dstOffset output parameter to receive the DST offset,
jpayne@69 527 * that is, the offset to be added to `rawOffset' to obtain the
jpayne@69 528 * total offset between local and GMT time. If DST is not in
jpayne@69 529 * effect, this value is zero; otherwise it is a positive value,
jpayne@69 530 * typically one hour.
jpayne@69 531 * @param ec input-output error code
jpayne@69 532 *
jpayne@69 533 * @stable ICU 2.8
jpayne@69 534 */
jpayne@69 535 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
jpayne@69 536 int32_t& dstOffset, UErrorCode& ec) const;
jpayne@69 537
jpayne@69 538 /**
jpayne@69 539 * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
jpayne@69 540 * to GMT to get local time, before taking daylight savings time into account).
jpayne@69 541 *
jpayne@69 542 * @param offsetMillis The new raw GMT offset for this time zone.
jpayne@69 543 * @stable ICU 2.0
jpayne@69 544 */
jpayne@69 545 virtual void setRawOffset(int32_t offsetMillis) = 0;
jpayne@69 546
jpayne@69 547 /**
jpayne@69 548 * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
jpayne@69 549 * to GMT to get local time, before taking daylight savings time into account).
jpayne@69 550 *
jpayne@69 551 * @return The TimeZone's raw GMT offset.
jpayne@69 552 * @stable ICU 2.0
jpayne@69 553 */
jpayne@69 554 virtual int32_t getRawOffset(void) const = 0;
jpayne@69 555
jpayne@69 556 /**
jpayne@69 557 * Fills in "ID" with the TimeZone's ID.
jpayne@69 558 *
jpayne@69 559 * @param ID Receives this TimeZone's ID.
jpayne@69 560 * @return A reference to 'ID'
jpayne@69 561 * @stable ICU 2.0
jpayne@69 562 */
jpayne@69 563 UnicodeString& getID(UnicodeString& ID) const;
jpayne@69 564
jpayne@69 565 /**
jpayne@69 566 * Sets the TimeZone's ID to the specified value. This doesn't affect any other
jpayne@69 567 * fields (for example, if you say<
jpayne@69 568 * blockquote><pre>
jpayne@69 569 * . TimeZone* foo = TimeZone::createTimeZone("America/New_York");
jpayne@69 570 * . foo.setID("America/Los_Angeles");
jpayne@69 571 * </pre>\htmlonly</blockquote>\endhtmlonly
jpayne@69 572 * the time zone's GMT offset and daylight-savings rules don't change to those for
jpayne@69 573 * Los Angeles. They're still those for New York. Only the ID has changed.)
jpayne@69 574 *
jpayne@69 575 * @param ID The new time zone ID.
jpayne@69 576 * @stable ICU 2.0
jpayne@69 577 */
jpayne@69 578 void setID(const UnicodeString& ID);
jpayne@69 579
jpayne@69 580 /**
jpayne@69 581 * Enum for use with getDisplayName
jpayne@69 582 * @stable ICU 2.4
jpayne@69 583 */
jpayne@69 584 enum EDisplayType {
jpayne@69 585 /**
jpayne@69 586 * Selector for short display name
jpayne@69 587 * @stable ICU 2.4
jpayne@69 588 */
jpayne@69 589 SHORT = 1,
jpayne@69 590 /**
jpayne@69 591 * Selector for long display name
jpayne@69 592 * @stable ICU 2.4
jpayne@69 593 */
jpayne@69 594 LONG,
jpayne@69 595 /**
jpayne@69 596 * Selector for short generic display name
jpayne@69 597 * @stable ICU 4.4
jpayne@69 598 */
jpayne@69 599 SHORT_GENERIC,
jpayne@69 600 /**
jpayne@69 601 * Selector for long generic display name
jpayne@69 602 * @stable ICU 4.4
jpayne@69 603 */
jpayne@69 604 LONG_GENERIC,
jpayne@69 605 /**
jpayne@69 606 * Selector for short display name derived
jpayne@69 607 * from time zone offset
jpayne@69 608 * @stable ICU 4.4
jpayne@69 609 */
jpayne@69 610 SHORT_GMT,
jpayne@69 611 /**
jpayne@69 612 * Selector for long display name derived
jpayne@69 613 * from time zone offset
jpayne@69 614 * @stable ICU 4.4
jpayne@69 615 */
jpayne@69 616 LONG_GMT,
jpayne@69 617 /**
jpayne@69 618 * Selector for short display name derived
jpayne@69 619 * from the time zone's fallback name
jpayne@69 620 * @stable ICU 4.4
jpayne@69 621 */
jpayne@69 622 SHORT_COMMONLY_USED,
jpayne@69 623 /**
jpayne@69 624 * Selector for long display name derived
jpayne@69 625 * from the time zone's fallback name
jpayne@69 626 * @stable ICU 4.4
jpayne@69 627 */
jpayne@69 628 GENERIC_LOCATION
jpayne@69 629 };
jpayne@69 630
jpayne@69 631 /**
jpayne@69 632 * Returns a name of this time zone suitable for presentation to the user
jpayne@69 633 * in the default locale.
jpayne@69 634 * This method returns the long name, not including daylight savings.
jpayne@69 635 * If the display name is not available for the locale,
jpayne@69 636 * then this method returns a string in the localized GMT offset format
jpayne@69 637 * such as <code>GMT[+-]HH:mm</code>.
jpayne@69 638 * @param result the human-readable name of this time zone in the default locale.
jpayne@69 639 * @return A reference to 'result'.
jpayne@69 640 * @stable ICU 2.0
jpayne@69 641 */
jpayne@69 642 UnicodeString& getDisplayName(UnicodeString& result) const;
jpayne@69 643
jpayne@69 644 /**
jpayne@69 645 * Returns a name of this time zone suitable for presentation to the user
jpayne@69 646 * in the specified locale.
jpayne@69 647 * This method returns the long name, not including daylight savings.
jpayne@69 648 * If the display name is not available for the locale,
jpayne@69 649 * then this method returns a string in the localized GMT offset format
jpayne@69 650 * such as <code>GMT[+-]HH:mm</code>.
jpayne@69 651 * @param locale the locale in which to supply the display name.
jpayne@69 652 * @param result the human-readable name of this time zone in the given locale
jpayne@69 653 * or in the default locale if the given locale is not recognized.
jpayne@69 654 * @return A reference to 'result'.
jpayne@69 655 * @stable ICU 2.0
jpayne@69 656 */
jpayne@69 657 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
jpayne@69 658
jpayne@69 659 /**
jpayne@69 660 * Returns a name of this time zone suitable for presentation to the user
jpayne@69 661 * in the default locale.
jpayne@69 662 * If the display name is not available for the locale,
jpayne@69 663 * then this method returns a string in the localized GMT offset format
jpayne@69 664 * such as <code>GMT[+-]HH:mm</code>.
jpayne@69 665 * @param inDaylight if true, return the daylight savings name.
jpayne@69 666 * @param style
jpayne@69 667 * @param result the human-readable name of this time zone in the default locale.
jpayne@69 668 * @return A reference to 'result'.
jpayne@69 669 * @stable ICU 2.0
jpayne@69 670 */
jpayne@69 671 UnicodeString& getDisplayName(UBool inDaylight, EDisplayType style, UnicodeString& result) const;
jpayne@69 672
jpayne@69 673 /**
jpayne@69 674 * Returns a name of this time zone suitable for presentation to the user
jpayne@69 675 * in the specified locale.
jpayne@69 676 * If the display name is not available for the locale,
jpayne@69 677 * then this method returns a string in the localized GMT offset format
jpayne@69 678 * such as <code>GMT[+-]HH:mm</code>.
jpayne@69 679 * @param inDaylight if true, return the daylight savings name.
jpayne@69 680 * @param style
jpayne@69 681 * @param locale the locale in which to supply the display name.
jpayne@69 682 * @param result the human-readable name of this time zone in the given locale
jpayne@69 683 * or in the default locale if the given locale is not recognized.
jpayne@69 684 * @return A reference to 'result'.
jpayne@69 685 * @stable ICU 2.0
jpayne@69 686 */
jpayne@69 687 UnicodeString& getDisplayName(UBool inDaylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
jpayne@69 688
jpayne@69 689 /**
jpayne@69 690 * Queries if this time zone uses daylight savings time.
jpayne@69 691 * @return true if this time zone uses daylight savings time,
jpayne@69 692 * false, otherwise.
jpayne@69 693 * <p><strong>Note:</strong>The default implementation of
jpayne@69 694 * ICU TimeZone uses the tz database, which supports historic
jpayne@69 695 * rule changes, for system time zones. With the implementation,
jpayne@69 696 * there are time zones that used daylight savings time in the
jpayne@69 697 * past, but no longer used currently. For example, Asia/Tokyo has
jpayne@69 698 * never used daylight savings time since 1951. Most clients would
jpayne@69 699 * expect that this method to return <code>FALSE</code> for such case.
jpayne@69 700 * The default implementation of this method returns <code>TRUE</code>
jpayne@69 701 * when the time zone uses daylight savings time in the current
jpayne@69 702 * (Gregorian) calendar year.
jpayne@69 703 * <p>In Java 7, <code>observesDaylightTime()</code> was added in
jpayne@69 704 * addition to <code>useDaylightTime()</code>. In Java, <code>useDaylightTime()</code>
jpayne@69 705 * only checks if daylight saving time is observed by the last known
jpayne@69 706 * rule. This specification might not be what most users would expect
jpayne@69 707 * if daylight saving time is currently observed, but not scheduled
jpayne@69 708 * in future. In this case, Java's <code>userDaylightTime()</code> returns
jpayne@69 709 * <code>false</code>. To resolve the issue, Java 7 added <code>observesDaylightTime()</code>,
jpayne@69 710 * which takes the current rule into account. The method <code>observesDaylightTime()</code>
jpayne@69 711 * was added in ICU4J for supporting API signature compatibility with JDK.
jpayne@69 712 * In general, ICU4C also provides JDK compatible methods, but the current
jpayne@69 713 * implementation <code>userDaylightTime()</code> serves the purpose
jpayne@69 714 * (takes the current rule into account), <code>observesDaylightTime()</code>
jpayne@69 715 * is not added in ICU4C. In addition to <code>useDaylightTime()</code>, ICU4C
jpayne@69 716 * <code>BasicTimeZone</code> class (Note that <code>TimeZone::createTimeZone(const UnicodeString &ID)</code>
jpayne@69 717 * always returns a <code>BasicTimeZone</code>) provides a series of methods allowing
jpayne@69 718 * historic and future time zone rule iteration, so you can check if daylight saving
jpayne@69 719 * time is observed or not within a given period.
jpayne@69 720 *
jpayne@69 721 * @stable ICU 2.0
jpayne@69 722 */
jpayne@69 723 virtual UBool useDaylightTime(void) const = 0;
jpayne@69 724
jpayne@69 725 #ifndef U_FORCE_HIDE_DEPRECATED_API
jpayne@69 726 /**
jpayne@69 727 * Queries if the given date is in daylight savings time in
jpayne@69 728 * this time zone.
jpayne@69 729 * This method is wasteful since it creates a new GregorianCalendar and
jpayne@69 730 * deletes it each time it is called. This is a deprecated method
jpayne@69 731 * and provided only for Java compatibility.
jpayne@69 732 *
jpayne@69 733 * @param date the given UDate.
jpayne@69 734 * @param status Output param filled in with success/error code.
jpayne@69 735 * @return true if the given date is in daylight savings time,
jpayne@69 736 * false, otherwise.
jpayne@69 737 * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
jpayne@69 738 */
jpayne@69 739 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
jpayne@69 740 #endif // U_FORCE_HIDE_DEPRECATED_API
jpayne@69 741
jpayne@69 742 /**
jpayne@69 743 * Returns true if this zone has the same rule and offset as another zone.
jpayne@69 744 * That is, if this zone differs only in ID, if at all.
jpayne@69 745 * @param other the <code>TimeZone</code> object to be compared with
jpayne@69 746 * @return true if the given zone is the same as this one,
jpayne@69 747 * with the possible exception of the ID
jpayne@69 748 * @stable ICU 2.0
jpayne@69 749 */
jpayne@69 750 virtual UBool hasSameRules(const TimeZone& other) const;
jpayne@69 751
jpayne@69 752 /**
jpayne@69 753 * Clones TimeZone objects polymorphically. Clients are responsible for deleting
jpayne@69 754 * the TimeZone object cloned.
jpayne@69 755 *
jpayne@69 756 * @return A new copy of this TimeZone object.
jpayne@69 757 * @stable ICU 2.0
jpayne@69 758 */
jpayne@69 759 virtual TimeZone* clone() const = 0;
jpayne@69 760
jpayne@69 761 /**
jpayne@69 762 * Return the class ID for this class. This is useful only for
jpayne@69 763 * comparing to a return value from getDynamicClassID().
jpayne@69 764 * @return The class ID for all objects of this class.
jpayne@69 765 * @stable ICU 2.0
jpayne@69 766 */
jpayne@69 767 static UClassID U_EXPORT2 getStaticClassID(void);
jpayne@69 768
jpayne@69 769 /**
jpayne@69 770 * Returns a unique class ID POLYMORPHICALLY. This method is to
jpayne@69 771 * implement a simple version of RTTI, since not all C++ compilers support genuine
jpayne@69 772 * RTTI. Polymorphic operator==() and clone() methods call this method.
jpayne@69 773 * <P>
jpayne@69 774 * Concrete subclasses of TimeZone must use the UOBJECT_DEFINE_RTTI_IMPLEMENTATION
jpayne@69 775 * macro from uobject.h in their implementation to provide correct RTTI information.
jpayne@69 776 * @return The class ID for this object. All objects of a given class have the
jpayne@69 777 * same class ID. Objects of other classes have different class IDs.
jpayne@69 778 * @stable ICU 2.0
jpayne@69 779 */
jpayne@69 780 virtual UClassID getDynamicClassID(void) const = 0;
jpayne@69 781
jpayne@69 782 /**
jpayne@69 783 * Returns the amount of time to be added to local standard time
jpayne@69 784 * to get local wall clock time.
jpayne@69 785 * <p>
jpayne@69 786 * The default implementation always returns 3600000 milliseconds
jpayne@69 787 * (i.e., one hour) if this time zone observes Daylight Saving
jpayne@69 788 * Time. Otherwise, 0 (zero) is returned.
jpayne@69 789 * <p>
jpayne@69 790 * If an underlying TimeZone implementation subclass supports
jpayne@69 791 * historical Daylight Saving Time changes, this method returns
jpayne@69 792 * the known latest daylight saving value.
jpayne@69 793 *
jpayne@69 794 * @return the amount of saving time in milliseconds
jpayne@69 795 * @stable ICU 3.6
jpayne@69 796 */
jpayne@69 797 virtual int32_t getDSTSavings() const;
jpayne@69 798
jpayne@69 799 /**
jpayne@69 800 * Gets the region code associated with the given
jpayne@69 801 * system time zone ID. The region code is either ISO 3166
jpayne@69 802 * 2-letter country code or UN M.49 3-digit area code.
jpayne@69 803 * When the time zone is not associated with a specific location,
jpayne@69 804 * for example - "Etc/UTC", "EST5EDT", then this method returns
jpayne@69 805 * "001" (UN M.49 area code for World).
jpayne@69 806 *
jpayne@69 807 * @param id The system time zone ID.
jpayne@69 808 * @param region Output buffer for receiving the region code.
jpayne@69 809 * @param capacity The size of the output buffer.
jpayne@69 810 * @param status Receives the status. When the given time zone ID
jpayne@69 811 * is not a known system time zone ID,
jpayne@69 812 * U_ILLEGAL_ARGUMENT_ERROR is set.
jpayne@69 813 * @return The length of the output region code.
jpayne@69 814 * @stable ICU 4.8
jpayne@69 815 */
jpayne@69 816 static int32_t U_EXPORT2 getRegion(const UnicodeString& id,
jpayne@69 817 char *region, int32_t capacity, UErrorCode& status);
jpayne@69 818
jpayne@69 819 protected:
jpayne@69 820
jpayne@69 821 /**
jpayne@69 822 * Default constructor. ID is initialized to the empty string.
jpayne@69 823 * @stable ICU 2.0
jpayne@69 824 */
jpayne@69 825 TimeZone();
jpayne@69 826
jpayne@69 827 /**
jpayne@69 828 * Construct a TimeZone with a given ID.
jpayne@69 829 * @param id a system time zone ID
jpayne@69 830 * @stable ICU 2.0
jpayne@69 831 */
jpayne@69 832 TimeZone(const UnicodeString &id);
jpayne@69 833
jpayne@69 834 /**
jpayne@69 835 * Copy constructor.
jpayne@69 836 * @param source the object to be copied.
jpayne@69 837 * @stable ICU 2.0
jpayne@69 838 */
jpayne@69 839 TimeZone(const TimeZone& source);
jpayne@69 840
jpayne@69 841 /**
jpayne@69 842 * Default assignment operator.
jpayne@69 843 * @param right the object to be copied.
jpayne@69 844 * @stable ICU 2.0
jpayne@69 845 */
jpayne@69 846 TimeZone& operator=(const TimeZone& right);
jpayne@69 847
jpayne@69 848 #ifndef U_HIDE_INTERNAL_API
jpayne@69 849 /**
jpayne@69 850 * Utility function. For internally loading rule data.
jpayne@69 851 * @param top Top resource bundle for tz data
jpayne@69 852 * @param ruleid ID of rule to load
jpayne@69 853 * @param oldbundle Old bundle to reuse or NULL
jpayne@69 854 * @param status Status parameter
jpayne@69 855 * @return either a new bundle or *oldbundle
jpayne@69 856 * @internal
jpayne@69 857 */
jpayne@69 858 static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
jpayne@69 859 #endif /* U_HIDE_INTERNAL_API */
jpayne@69 860
jpayne@69 861 private:
jpayne@69 862 friend class ZoneMeta;
jpayne@69 863
jpayne@69 864
jpayne@69 865 static TimeZone* createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
jpayne@69 866
jpayne@69 867 /**
jpayne@69 868 * Finds the given ID in the Olson tzdata. If the given ID is found in the tzdata,
jpayne@69 869 * returns the pointer to the ID resource. This method is exposed through ZoneMeta class
jpayne@69 870 * for ICU internal implementation and useful for building hashtable using a time zone
jpayne@69 871 * ID as a key.
jpayne@69 872 * @param id zone id string
jpayne@69 873 * @return the pointer of the ID resource, or NULL.
jpayne@69 874 */
jpayne@69 875 static const char16_t* findID(const UnicodeString& id);
jpayne@69 876
jpayne@69 877 /**
jpayne@69 878 * Resolve a link in Olson tzdata. When the given id is known and it's not a link,
jpayne@69 879 * the id itself is returned. When the given id is known and it is a link, then
jpayne@69 880 * dereferenced zone id is returned. When the given id is unknown, then it returns
jpayne@69 881 * NULL.
jpayne@69 882 * @param id zone id string
jpayne@69 883 * @return the dereferenced zone or NULL
jpayne@69 884 */
jpayne@69 885 static const char16_t* dereferOlsonLink(const UnicodeString& id);
jpayne@69 886
jpayne@69 887 /**
jpayne@69 888 * Returns the region code associated with the given zone,
jpayne@69 889 * or NULL if the zone is not known.
jpayne@69 890 * @param id zone id string
jpayne@69 891 * @return the region associated with the given zone
jpayne@69 892 */
jpayne@69 893 static const char16_t* getRegion(const UnicodeString& id);
jpayne@69 894
jpayne@69 895 public:
jpayne@69 896 #ifndef U_HIDE_INTERNAL_API
jpayne@69 897 /**
jpayne@69 898 * Returns the region code associated with the given zone,
jpayne@69 899 * or NULL if the zone is not known.
jpayne@69 900 * @param id zone id string
jpayne@69 901 * @param status Status parameter
jpayne@69 902 * @return the region associated with the given zone
jpayne@69 903 * @internal
jpayne@69 904 */
jpayne@69 905 static const char16_t* getRegion(const UnicodeString& id, UErrorCode& status);
jpayne@69 906 #endif /* U_HIDE_INTERNAL_API */
jpayne@69 907
jpayne@69 908 private:
jpayne@69 909 /**
jpayne@69 910 * Parses the given custom time zone identifier
jpayne@69 911 * @param id id A string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or
jpayne@69 912 * GMT[+-]hh.
jpayne@69 913 * @param sign Receves parsed sign, 1 for positive, -1 for negative.
jpayne@69 914 * @param hour Receives parsed hour field
jpayne@69 915 * @param minute Receives parsed minute field
jpayne@69 916 * @param second Receives parsed second field
jpayne@69 917 * @return Returns TRUE when the given custom id is valid.
jpayne@69 918 */
jpayne@69 919 static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,
jpayne@69 920 int32_t& minute, int32_t& second);
jpayne@69 921
jpayne@69 922 /**
jpayne@69 923 * Parse a custom time zone identifier and return the normalized
jpayne@69 924 * custom time zone identifier for the given custom id string.
jpayne@69 925 * @param id a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or
jpayne@69 926 * GMT[+-]hh.
jpayne@69 927 * @param normalized Receives the normalized custom ID
jpayne@69 928 * @param status Receives the status. When the input ID string is invalid,
jpayne@69 929 * U_ILLEGAL_ARGUMENT_ERROR is set.
jpayne@69 930 * @return The normalized custom id string.
jpayne@69 931 */
jpayne@69 932 static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized,
jpayne@69 933 UErrorCode& status);
jpayne@69 934
jpayne@69 935 /**
jpayne@69 936 * Returns the normalized custom time zone ID for the given offset fields.
jpayne@69 937 * @param hour offset hours
jpayne@69 938 * @param min offset minutes
jpayne@69 939 * @param sec offset seconds
jpayne@69 940 * @param negative sign of the offset, TRUE for negative offset.
jpayne@69 941 * @param id Receves the format result (normalized custom ID)
jpayne@69 942 * @return The reference to id
jpayne@69 943 */
jpayne@69 944 static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec,
jpayne@69 945 UBool negative, UnicodeString& id);
jpayne@69 946
jpayne@69 947 UnicodeString fID; // this time zone's ID
jpayne@69 948
jpayne@69 949 friend class TZEnumeration;
jpayne@69 950 };
jpayne@69 951
jpayne@69 952
jpayne@69 953 // -------------------------------------
jpayne@69 954
jpayne@69 955 inline UnicodeString&
jpayne@69 956 TimeZone::getID(UnicodeString& ID) const
jpayne@69 957 {
jpayne@69 958 ID = fID;
jpayne@69 959 return ID;
jpayne@69 960 }
jpayne@69 961
jpayne@69 962 // -------------------------------------
jpayne@69 963
jpayne@69 964 inline void
jpayne@69 965 TimeZone::setID(const UnicodeString& ID)
jpayne@69 966 {
jpayne@69 967 fID = ID;
jpayne@69 968 }
jpayne@69 969 U_NAMESPACE_END
jpayne@69 970
jpayne@69 971 #endif /* #if !UCONFIG_NO_FORMATTING */
jpayne@69 972
jpayne@69 973 #endif /* U_SHOW_CPLUSPLUS_API */
jpayne@69 974
jpayne@69 975 #endif //_TIMEZONE
jpayne@69 976 //eof