annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/datefmt.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-2016, International Business Machines
jpayne@69 6 * Corporation and others. All Rights Reserved.
jpayne@69 7 ********************************************************************************
jpayne@69 8 *
jpayne@69 9 * File DATEFMT.H
jpayne@69 10 *
jpayne@69 11 * Modification History:
jpayne@69 12 *
jpayne@69 13 * Date Name Description
jpayne@69 14 * 02/19/97 aliu Converted from java.
jpayne@69 15 * 04/01/97 aliu Added support for centuries.
jpayne@69 16 * 07/23/98 stephen JDK 1.2 sync
jpayne@69 17 * 11/15/99 weiv Added support for week of year/day of week formatting
jpayne@69 18 ********************************************************************************
jpayne@69 19 */
jpayne@69 20
jpayne@69 21 #ifndef DATEFMT_H
jpayne@69 22 #define DATEFMT_H
jpayne@69 23
jpayne@69 24 #include "unicode/utypes.h"
jpayne@69 25
jpayne@69 26 #if U_SHOW_CPLUSPLUS_API
jpayne@69 27
jpayne@69 28 #if !UCONFIG_NO_FORMATTING
jpayne@69 29
jpayne@69 30 #include "unicode/udat.h"
jpayne@69 31 #include "unicode/calendar.h"
jpayne@69 32 #include "unicode/numfmt.h"
jpayne@69 33 #include "unicode/format.h"
jpayne@69 34 #include "unicode/locid.h"
jpayne@69 35 #include "unicode/enumset.h"
jpayne@69 36 #include "unicode/udisplaycontext.h"
jpayne@69 37
jpayne@69 38 /**
jpayne@69 39 * \file
jpayne@69 40 * \brief C++ API: Abstract class for converting dates.
jpayne@69 41 */
jpayne@69 42
jpayne@69 43 U_NAMESPACE_BEGIN
jpayne@69 44
jpayne@69 45 class TimeZone;
jpayne@69 46 class DateTimePatternGenerator;
jpayne@69 47
jpayne@69 48 /**
jpayne@69 49 * \cond
jpayne@69 50 * Export an explicit template instantiation. (See digitlst.h, datefmt.h, and others.)
jpayne@69 51 * (When building DLLs for Windows this is required.)
jpayne@69 52 */
jpayne@69 53 #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN && !defined(U_IN_DOXYGEN)
jpayne@69 54 template class U_I18N_API EnumSet<UDateFormatBooleanAttribute,
jpayne@69 55 0,
jpayne@69 56 UDAT_BOOLEAN_ATTRIBUTE_COUNT>;
jpayne@69 57 #endif
jpayne@69 58 /** \endcond */
jpayne@69 59
jpayne@69 60 /**
jpayne@69 61 * DateFormat is an abstract class for a family of classes that convert dates and
jpayne@69 62 * times from their internal representations to textual form and back again in a
jpayne@69 63 * language-independent manner. Converting from the internal representation (milliseconds
jpayne@69 64 * since midnight, January 1, 1970) to text is known as "formatting," and converting
jpayne@69 65 * from text to millis is known as "parsing." We currently define only one concrete
jpayne@69 66 * subclass of DateFormat: SimpleDateFormat, which can handle pretty much all normal
jpayne@69 67 * date formatting and parsing actions.
jpayne@69 68 * <P>
jpayne@69 69 * DateFormat helps you to format and parse dates for any locale. Your code can
jpayne@69 70 * be completely independent of the locale conventions for months, days of the
jpayne@69 71 * week, or even the calendar format: lunar vs. solar.
jpayne@69 72 * <P>
jpayne@69 73 * To format a date for the current Locale, use one of the static factory
jpayne@69 74 * methods:
jpayne@69 75 * <pre>
jpayne@69 76 * \code
jpayne@69 77 * DateFormat* dfmt = DateFormat::createDateInstance();
jpayne@69 78 * UDate myDate = Calendar::getNow();
jpayne@69 79 * UnicodeString myString;
jpayne@69 80 * myString = dfmt->format( myDate, myString );
jpayne@69 81 * \endcode
jpayne@69 82 * </pre>
jpayne@69 83 * If you are formatting multiple numbers, it is more efficient to get the
jpayne@69 84 * format and use it multiple times so that the system doesn't have to fetch the
jpayne@69 85 * information about the local language and country conventions multiple times.
jpayne@69 86 * <pre>
jpayne@69 87 * \code
jpayne@69 88 * DateFormat* df = DateFormat::createDateInstance();
jpayne@69 89 * UnicodeString myString;
jpayne@69 90 * UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
jpayne@69 91 * for (int32_t i = 0; i < 3; ++i) {
jpayne@69 92 * myString.remove();
jpayne@69 93 * cout << df->format( myDateArr[i], myString ) << endl;
jpayne@69 94 * }
jpayne@69 95 * \endcode
jpayne@69 96 * </pre>
jpayne@69 97 * To get specific fields of a date, you can use UFieldPosition to
jpayne@69 98 * get specific fields.
jpayne@69 99 * <pre>
jpayne@69 100 * \code
jpayne@69 101 * DateFormat* dfmt = DateFormat::createDateInstance();
jpayne@69 102 * FieldPosition pos(DateFormat::YEAR_FIELD);
jpayne@69 103 * UnicodeString myString;
jpayne@69 104 * myString = dfmt->format( myDate, myString );
jpayne@69 105 * cout << myString << endl;
jpayne@69 106 * cout << pos.getBeginIndex() << "," << pos. getEndIndex() << endl;
jpayne@69 107 * \endcode
jpayne@69 108 * </pre>
jpayne@69 109 * To format a date for a different Locale, specify it in the call to
jpayne@69 110 * createDateInstance().
jpayne@69 111 * <pre>
jpayne@69 112 * \code
jpayne@69 113 * DateFormat* df =
jpayne@69 114 * DateFormat::createDateInstance( DateFormat::SHORT, Locale::getFrance());
jpayne@69 115 * \endcode
jpayne@69 116 * </pre>
jpayne@69 117 * You can use a DateFormat to parse also.
jpayne@69 118 * <pre>
jpayne@69 119 * \code
jpayne@69 120 * UErrorCode status = U_ZERO_ERROR;
jpayne@69 121 * UDate myDate = df->parse(myString, status);
jpayne@69 122 * \endcode
jpayne@69 123 * </pre>
jpayne@69 124 * Use createDateInstance() to produce the normal date format for that country.
jpayne@69 125 * There are other static factory methods available. Use createTimeInstance()
jpayne@69 126 * to produce the normal time format for that country. Use createDateTimeInstance()
jpayne@69 127 * to produce a DateFormat that formats both date and time. You can pass in
jpayne@69 128 * different options to these factory methods to control the length of the
jpayne@69 129 * result; from SHORT to MEDIUM to LONG to FULL. The exact result depends on the
jpayne@69 130 * locale, but generally:
jpayne@69 131 * <ul type=round>
jpayne@69 132 * <li> SHORT is completely numeric, such as 12/13/52 or 3:30pm
jpayne@69 133 * <li> MEDIUM is longer, such as Jan 12, 1952
jpayne@69 134 * <li> LONG is longer, such as January 12, 1952 or 3:30:32pm
jpayne@69 135 * <li> FULL is pretty completely specified, such as
jpayne@69 136 * Tuesday, April 12, 1952 AD or 3:30:42pm PST.
jpayne@69 137 * </ul>
jpayne@69 138 * You can also set the time zone on the format if you wish. If you want even
jpayne@69 139 * more control over the format or parsing, (or want to give your users more
jpayne@69 140 * control), you can try casting the DateFormat you get from the factory methods
jpayne@69 141 * to a SimpleDateFormat. This will work for the majority of countries; just
jpayne@69 142 * remember to chck getDynamicClassID() before carrying out the cast.
jpayne@69 143 * <P>
jpayne@69 144 * You can also use forms of the parse and format methods with ParsePosition and
jpayne@69 145 * FieldPosition to allow you to
jpayne@69 146 * <ul type=round>
jpayne@69 147 * <li> Progressively parse through pieces of a string.
jpayne@69 148 * <li> Align any particular field, or find out where it is for selection
jpayne@69 149 * on the screen.
jpayne@69 150 * </ul>
jpayne@69 151 *
jpayne@69 152 * <p><em>User subclasses are not supported.</em> While clients may write
jpayne@69 153 * subclasses, such code will not necessarily work and will not be
jpayne@69 154 * guaranteed to work stably from release to release.
jpayne@69 155 */
jpayne@69 156 class U_I18N_API DateFormat : public Format {
jpayne@69 157 public:
jpayne@69 158
jpayne@69 159 /**
jpayne@69 160 * Constants for various style patterns. These reflect the order of items in
jpayne@69 161 * the DateTimePatterns resource. There are 4 time patterns, 4 date patterns,
jpayne@69 162 * the default date-time pattern, and 4 date-time patterns. Each block of 4 values
jpayne@69 163 * in the resource occurs in the order full, long, medium, short.
jpayne@69 164 * @stable ICU 2.4
jpayne@69 165 */
jpayne@69 166 enum EStyle
jpayne@69 167 {
jpayne@69 168 kNone = -1,
jpayne@69 169
jpayne@69 170 kFull = 0,
jpayne@69 171 kLong = 1,
jpayne@69 172 kMedium = 2,
jpayne@69 173 kShort = 3,
jpayne@69 174
jpayne@69 175 kDateOffset = kShort + 1,
jpayne@69 176 // kFull + kDateOffset = 4
jpayne@69 177 // kLong + kDateOffset = 5
jpayne@69 178 // kMedium + kDateOffset = 6
jpayne@69 179 // kShort + kDateOffset = 7
jpayne@69 180
jpayne@69 181 kDateTime = 8,
jpayne@69 182 // Default DateTime
jpayne@69 183
jpayne@69 184 kDateTimeOffset = kDateTime + 1,
jpayne@69 185 // kFull + kDateTimeOffset = 9
jpayne@69 186 // kLong + kDateTimeOffset = 10
jpayne@69 187 // kMedium + kDateTimeOffset = 11
jpayne@69 188 // kShort + kDateTimeOffset = 12
jpayne@69 189
jpayne@69 190 // relative dates
jpayne@69 191 kRelative = (1 << 7),
jpayne@69 192
jpayne@69 193 kFullRelative = (kFull | kRelative),
jpayne@69 194
jpayne@69 195 kLongRelative = kLong | kRelative,
jpayne@69 196
jpayne@69 197 kMediumRelative = kMedium | kRelative,
jpayne@69 198
jpayne@69 199 kShortRelative = kShort | kRelative,
jpayne@69 200
jpayne@69 201
jpayne@69 202 kDefault = kMedium,
jpayne@69 203
jpayne@69 204
jpayne@69 205
jpayne@69 206 /**
jpayne@69 207 * These constants are provided for backwards compatibility only.
jpayne@69 208 * Please use the C++ style constants defined above.
jpayne@69 209 */
jpayne@69 210 FULL = kFull,
jpayne@69 211 LONG = kLong,
jpayne@69 212 MEDIUM = kMedium,
jpayne@69 213 SHORT = kShort,
jpayne@69 214 DEFAULT = kDefault,
jpayne@69 215 DATE_OFFSET = kDateOffset,
jpayne@69 216 NONE = kNone,
jpayne@69 217 DATE_TIME = kDateTime
jpayne@69 218 };
jpayne@69 219
jpayne@69 220 /**
jpayne@69 221 * Destructor.
jpayne@69 222 * @stable ICU 2.0
jpayne@69 223 */
jpayne@69 224 virtual ~DateFormat();
jpayne@69 225
jpayne@69 226 /**
jpayne@69 227 * Clones this object polymorphically.
jpayne@69 228 * The caller owns the result and should delete it when done.
jpayne@69 229 * @return clone, or nullptr if an error occurred
jpayne@69 230 * @stable ICU 2.0
jpayne@69 231 */
jpayne@69 232 virtual DateFormat* clone() const = 0;
jpayne@69 233
jpayne@69 234 /**
jpayne@69 235 * Equality operator. Returns true if the two formats have the same behavior.
jpayne@69 236 * @stable ICU 2.0
jpayne@69 237 */
jpayne@69 238 virtual UBool operator==(const Format&) const;
jpayne@69 239
jpayne@69 240
jpayne@69 241 using Format::format;
jpayne@69 242
jpayne@69 243 /**
jpayne@69 244 * Format an object to produce a string. This method handles Formattable
jpayne@69 245 * objects with a UDate type. If a the Formattable object type is not a Date,
jpayne@69 246 * then it returns a failing UErrorCode.
jpayne@69 247 *
jpayne@69 248 * @param obj The object to format. Must be a Date.
jpayne@69 249 * @param appendTo Output parameter to receive result.
jpayne@69 250 * Result is appended to existing contents.
jpayne@69 251 * @param pos On input: an alignment field, if desired.
jpayne@69 252 * On output: the offsets of the alignment field.
jpayne@69 253 * @param status Output param filled with success/failure status.
jpayne@69 254 * @return Reference to 'appendTo' parameter.
jpayne@69 255 * @stable ICU 2.0
jpayne@69 256 */
jpayne@69 257 virtual UnicodeString& format(const Formattable& obj,
jpayne@69 258 UnicodeString& appendTo,
jpayne@69 259 FieldPosition& pos,
jpayne@69 260 UErrorCode& status) const;
jpayne@69 261
jpayne@69 262 /**
jpayne@69 263 * Format an object to produce a string. This method handles Formattable
jpayne@69 264 * objects with a UDate type. If a the Formattable object type is not a Date,
jpayne@69 265 * then it returns a failing UErrorCode.
jpayne@69 266 *
jpayne@69 267 * @param obj The object to format. Must be a Date.
jpayne@69 268 * @param appendTo Output parameter to receive result.
jpayne@69 269 * Result is appended to existing contents.
jpayne@69 270 * @param posIter On return, can be used to iterate over positions
jpayne@69 271 * of fields generated by this format call. Field values
jpayne@69 272 * are defined in UDateFormatField. Can be NULL.
jpayne@69 273 * @param status Output param filled with success/failure status.
jpayne@69 274 * @return Reference to 'appendTo' parameter.
jpayne@69 275 * @stable ICU 4.4
jpayne@69 276 */
jpayne@69 277 virtual UnicodeString& format(const Formattable& obj,
jpayne@69 278 UnicodeString& appendTo,
jpayne@69 279 FieldPositionIterator* posIter,
jpayne@69 280 UErrorCode& status) const;
jpayne@69 281 /**
jpayne@69 282 * Formats a date into a date/time string. This is an abstract method which
jpayne@69 283 * concrete subclasses must implement.
jpayne@69 284 * <P>
jpayne@69 285 * On input, the FieldPosition parameter may have its "field" member filled with
jpayne@69 286 * an enum value specifying a field. On output, the FieldPosition will be filled
jpayne@69 287 * in with the text offsets for that field.
jpayne@69 288 * <P> For example, given a time text
jpayne@69 289 * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
jpayne@69 290 * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
jpayne@69 291 * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
jpayne@69 292 * <P> Notice
jpayne@69 293 * that if the same time field appears more than once in a pattern, the status will
jpayne@69 294 * be set for the first occurence of that time field. For instance,
jpayne@69 295 * formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
jpayne@69 296 * using the pattern "h a z (zzzz)" and the alignment field
jpayne@69 297 * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
jpayne@69 298 * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
jpayne@69 299 * occurence of the timezone pattern character 'z'.
jpayne@69 300 *
jpayne@69 301 * @param cal Calendar set to the date and time to be formatted
jpayne@69 302 * into a date/time string. When the calendar type is
jpayne@69 303 * different from the internal calendar held by this
jpayne@69 304 * DateFormat instance, the date and the time zone will
jpayne@69 305 * be inherited from the input calendar, but other calendar
jpayne@69 306 * field values will be calculated by the internal calendar.
jpayne@69 307 * @param appendTo Output parameter to receive result.
jpayne@69 308 * Result is appended to existing contents.
jpayne@69 309 * @param fieldPosition On input: an alignment field, if desired (see examples above)
jpayne@69 310 * On output: the offsets of the alignment field (see examples above)
jpayne@69 311 * @return Reference to 'appendTo' parameter.
jpayne@69 312 * @stable ICU 2.1
jpayne@69 313 */
jpayne@69 314 virtual UnicodeString& format( Calendar& cal,
jpayne@69 315 UnicodeString& appendTo,
jpayne@69 316 FieldPosition& fieldPosition) const = 0;
jpayne@69 317
jpayne@69 318 /**
jpayne@69 319 * Formats a date into a date/time string. Subclasses should implement this method.
jpayne@69 320 *
jpayne@69 321 * @param cal Calendar set to the date and time to be formatted
jpayne@69 322 * into a date/time string. When the calendar type is
jpayne@69 323 * different from the internal calendar held by this
jpayne@69 324 * DateFormat instance, the date and the time zone will
jpayne@69 325 * be inherited from the input calendar, but other calendar
jpayne@69 326 * field values will be calculated by the internal calendar.
jpayne@69 327 * @param appendTo Output parameter to receive result.
jpayne@69 328 * Result is appended to existing contents.
jpayne@69 329 * @param posIter On return, can be used to iterate over positions
jpayne@69 330 * of fields generated by this format call. Field values
jpayne@69 331 * are defined in UDateFormatField. Can be NULL.
jpayne@69 332 * @param status error status.
jpayne@69 333 * @return Reference to 'appendTo' parameter.
jpayne@69 334 * @stable ICU 4.4
jpayne@69 335 */
jpayne@69 336 virtual UnicodeString& format(Calendar& cal,
jpayne@69 337 UnicodeString& appendTo,
jpayne@69 338 FieldPositionIterator* posIter,
jpayne@69 339 UErrorCode& status) const;
jpayne@69 340 /**
jpayne@69 341 * Formats a UDate into a date/time string.
jpayne@69 342 * <P>
jpayne@69 343 * On input, the FieldPosition parameter may have its "field" member filled with
jpayne@69 344 * an enum value specifying a field. On output, the FieldPosition will be filled
jpayne@69 345 * in with the text offsets for that field.
jpayne@69 346 * <P> For example, given a time text
jpayne@69 347 * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
jpayne@69 348 * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
jpayne@69 349 * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
jpayne@69 350 * <P> Notice
jpayne@69 351 * that if the same time field appears more than once in a pattern, the status will
jpayne@69 352 * be set for the first occurence of that time field. For instance,
jpayne@69 353 * formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
jpayne@69 354 * using the pattern "h a z (zzzz)" and the alignment field
jpayne@69 355 * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
jpayne@69 356 * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
jpayne@69 357 * occurence of the timezone pattern character 'z'.
jpayne@69 358 *
jpayne@69 359 * @param date UDate to be formatted into a date/time string.
jpayne@69 360 * @param appendTo Output parameter to receive result.
jpayne@69 361 * Result is appended to existing contents.
jpayne@69 362 * @param fieldPosition On input: an alignment field, if desired (see examples above)
jpayne@69 363 * On output: the offsets of the alignment field (see examples above)
jpayne@69 364 * @return Reference to 'appendTo' parameter.
jpayne@69 365 * @stable ICU 2.0
jpayne@69 366 */
jpayne@69 367 UnicodeString& format( UDate date,
jpayne@69 368 UnicodeString& appendTo,
jpayne@69 369 FieldPosition& fieldPosition) const;
jpayne@69 370
jpayne@69 371 /**
jpayne@69 372 * Formats a UDate into a date/time string.
jpayne@69 373 *
jpayne@69 374 * @param date UDate to be formatted into a date/time string.
jpayne@69 375 * @param appendTo Output parameter to receive result.
jpayne@69 376 * Result is appended to existing contents.
jpayne@69 377 * @param posIter On return, can be used to iterate over positions
jpayne@69 378 * of fields generated by this format call. Field values
jpayne@69 379 * are defined in UDateFormatField. Can be NULL.
jpayne@69 380 * @param status error status.
jpayne@69 381 * @return Reference to 'appendTo' parameter.
jpayne@69 382 * @stable ICU 4.4
jpayne@69 383 */
jpayne@69 384 UnicodeString& format(UDate date,
jpayne@69 385 UnicodeString& appendTo,
jpayne@69 386 FieldPositionIterator* posIter,
jpayne@69 387 UErrorCode& status) const;
jpayne@69 388 /**
jpayne@69 389 * Formats a UDate into a date/time string. If there is a problem, you won't
jpayne@69 390 * know, using this method. Use the overloaded format() method which takes a
jpayne@69 391 * FieldPosition& to detect formatting problems.
jpayne@69 392 *
jpayne@69 393 * @param date The UDate value to be formatted into a string.
jpayne@69 394 * @param appendTo Output parameter to receive result.
jpayne@69 395 * Result is appended to existing contents.
jpayne@69 396 * @return Reference to 'appendTo' parameter.
jpayne@69 397 * @stable ICU 2.0
jpayne@69 398 */
jpayne@69 399 UnicodeString& format(UDate date, UnicodeString& appendTo) const;
jpayne@69 400
jpayne@69 401 /**
jpayne@69 402 * Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT"
jpayne@69 403 * will be parsed into a UDate that is equivalent to Date(837039928046).
jpayne@69 404 * Parsing begins at the beginning of the string and proceeds as far as
jpayne@69 405 * possible. Assuming no parse errors were encountered, this function
jpayne@69 406 * doesn't return any information about how much of the string was consumed
jpayne@69 407 * by the parsing. If you need that information, use the version of
jpayne@69 408 * parse() that takes a ParsePosition.
jpayne@69 409 * <P>
jpayne@69 410 * By default, parsing is lenient: If the input is not in the form used by
jpayne@69 411 * this object's format method but can still be parsed as a date, then the
jpayne@69 412 * parse succeeds. Clients may insist on strict adherence to the format by
jpayne@69 413 * calling setLenient(false).
jpayne@69 414 * @see DateFormat::setLenient(boolean)
jpayne@69 415 * <P>
jpayne@69 416 * Note that the normal date formats associated with some calendars - such
jpayne@69 417 * as the Chinese lunar calendar - do not specify enough fields to enable
jpayne@69 418 * dates to be parsed unambiguously. In the case of the Chinese lunar
jpayne@69 419 * calendar, while the year within the current 60-year cycle is specified,
jpayne@69 420 * the number of such cycles since the start date of the calendar (in the
jpayne@69 421 * ERA field of the Calendar object) is not normally part of the format,
jpayne@69 422 * and parsing may assume the wrong era. For cases such as this it is
jpayne@69 423 * recommended that clients parse using the method
jpayne@69 424 * parse(const UnicodeString&, Calendar& cal, ParsePosition&)
jpayne@69 425 * with the Calendar passed in set to the current date, or to a date
jpayne@69 426 * within the era/cycle that should be assumed if absent in the format.
jpayne@69 427 *
jpayne@69 428 * @param text The date/time string to be parsed into a UDate value.
jpayne@69 429 * @param status Output param to be set to success/failure code. If
jpayne@69 430 * 'text' cannot be parsed, it will be set to a failure
jpayne@69 431 * code.
jpayne@69 432 * @return The parsed UDate value, if successful.
jpayne@69 433 * @stable ICU 2.0
jpayne@69 434 */
jpayne@69 435 virtual UDate parse( const UnicodeString& text,
jpayne@69 436 UErrorCode& status) const;
jpayne@69 437
jpayne@69 438 /**
jpayne@69 439 * Parse a date/time string beginning at the given parse position. For
jpayne@69 440 * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
jpayne@69 441 * that is equivalent to Date(837039928046).
jpayne@69 442 * <P>
jpayne@69 443 * By default, parsing is lenient: If the input is not in the form used by
jpayne@69 444 * this object's format method but can still be parsed as a date, then the
jpayne@69 445 * parse succeeds. Clients may insist on strict adherence to the format by
jpayne@69 446 * calling setLenient(false).
jpayne@69 447 * @see DateFormat::setLenient(boolean)
jpayne@69 448 *
jpayne@69 449 * @param text The date/time string to be parsed.
jpayne@69 450 * @param cal A Calendar set on input to the date and time to be used for
jpayne@69 451 * missing values in the date/time string being parsed, and set
jpayne@69 452 * on output to the parsed date/time. When the calendar type is
jpayne@69 453 * different from the internal calendar held by this DateFormat
jpayne@69 454 * instance, the internal calendar will be cloned to a work
jpayne@69 455 * calendar set to the same milliseconds and time zone as the
jpayne@69 456 * cal parameter, field values will be parsed based on the work
jpayne@69 457 * calendar, then the result (milliseconds and time zone) will
jpayne@69 458 * be set in this calendar.
jpayne@69 459 * @param pos On input, the position at which to start parsing; on
jpayne@69 460 * output, the position at which parsing terminated, or the
jpayne@69 461 * start position if the parse failed.
jpayne@69 462 * @stable ICU 2.1
jpayne@69 463 */
jpayne@69 464 virtual void parse( const UnicodeString& text,
jpayne@69 465 Calendar& cal,
jpayne@69 466 ParsePosition& pos) const = 0;
jpayne@69 467
jpayne@69 468 /**
jpayne@69 469 * Parse a date/time string beginning at the given parse position. For
jpayne@69 470 * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
jpayne@69 471 * that is equivalent to Date(837039928046).
jpayne@69 472 * <P>
jpayne@69 473 * By default, parsing is lenient: If the input is not in the form used by
jpayne@69 474 * this object's format method but can still be parsed as a date, then the
jpayne@69 475 * parse succeeds. Clients may insist on strict adherence to the format by
jpayne@69 476 * calling setLenient(false).
jpayne@69 477 * @see DateFormat::setLenient(boolean)
jpayne@69 478 * <P>
jpayne@69 479 * Note that the normal date formats associated with some calendars - such
jpayne@69 480 * as the Chinese lunar calendar - do not specify enough fields to enable
jpayne@69 481 * dates to be parsed unambiguously. In the case of the Chinese lunar
jpayne@69 482 * calendar, while the year within the current 60-year cycle is specified,
jpayne@69 483 * the number of such cycles since the start date of the calendar (in the
jpayne@69 484 * ERA field of the Calendar object) is not normally part of the format,
jpayne@69 485 * and parsing may assume the wrong era. For cases such as this it is
jpayne@69 486 * recommended that clients parse using the method
jpayne@69 487 * parse(const UnicodeString&, Calendar& cal, ParsePosition&)
jpayne@69 488 * with the Calendar passed in set to the current date, or to a date
jpayne@69 489 * within the era/cycle that should be assumed if absent in the format.
jpayne@69 490 *
jpayne@69 491 * @param text The date/time string to be parsed into a UDate value.
jpayne@69 492 * @param pos On input, the position at which to start parsing; on
jpayne@69 493 * output, the position at which parsing terminated, or the
jpayne@69 494 * start position if the parse failed.
jpayne@69 495 * @return A valid UDate if the input could be parsed.
jpayne@69 496 * @stable ICU 2.0
jpayne@69 497 */
jpayne@69 498 UDate parse( const UnicodeString& text,
jpayne@69 499 ParsePosition& pos) const;
jpayne@69 500
jpayne@69 501 /**
jpayne@69 502 * Parse a string to produce an object. This methods handles parsing of
jpayne@69 503 * date/time strings into Formattable objects with UDate types.
jpayne@69 504 * <P>
jpayne@69 505 * Before calling, set parse_pos.index to the offset you want to start
jpayne@69 506 * parsing at in the source. After calling, parse_pos.index is the end of
jpayne@69 507 * the text you parsed. If error occurs, index is unchanged.
jpayne@69 508 * <P>
jpayne@69 509 * When parsing, leading whitespace is discarded (with a successful parse),
jpayne@69 510 * while trailing whitespace is left as is.
jpayne@69 511 * <P>
jpayne@69 512 * See Format::parseObject() for more.
jpayne@69 513 *
jpayne@69 514 * @param source The string to be parsed into an object.
jpayne@69 515 * @param result Formattable to be set to the parse result.
jpayne@69 516 * If parse fails, return contents are undefined.
jpayne@69 517 * @param parse_pos The position to start parsing at. Upon return
jpayne@69 518 * this param is set to the position after the
jpayne@69 519 * last character successfully parsed. If the
jpayne@69 520 * source is not parsed successfully, this param
jpayne@69 521 * will remain unchanged.
jpayne@69 522 * @stable ICU 2.0
jpayne@69 523 */
jpayne@69 524 virtual void parseObject(const UnicodeString& source,
jpayne@69 525 Formattable& result,
jpayne@69 526 ParsePosition& parse_pos) const;
jpayne@69 527
jpayne@69 528 /**
jpayne@69 529 * Create a default date/time formatter that uses the SHORT style for both
jpayne@69 530 * the date and the time.
jpayne@69 531 *
jpayne@69 532 * @return A date/time formatter which the caller owns.
jpayne@69 533 * @stable ICU 2.0
jpayne@69 534 */
jpayne@69 535 static DateFormat* U_EXPORT2 createInstance(void);
jpayne@69 536
jpayne@69 537 /**
jpayne@69 538 * Creates a time formatter with the given formatting style for the given
jpayne@69 539 * locale.
jpayne@69 540 *
jpayne@69 541 * @param style The given formatting style. For example,
jpayne@69 542 * SHORT for "h:mm a" in the US locale. Relative
jpayne@69 543 * time styles are not currently supported.
jpayne@69 544 * @param aLocale The given locale.
jpayne@69 545 * @return A time formatter which the caller owns.
jpayne@69 546 * @stable ICU 2.0
jpayne@69 547 */
jpayne@69 548 static DateFormat* U_EXPORT2 createTimeInstance(EStyle style = kDefault,
jpayne@69 549 const Locale& aLocale = Locale::getDefault());
jpayne@69 550
jpayne@69 551 /**
jpayne@69 552 * Creates a date formatter with the given formatting style for the given
jpayne@69 553 * const locale.
jpayne@69 554 *
jpayne@69 555 * @param style The given formatting style. For example, SHORT for "M/d/yy" in the
jpayne@69 556 * US locale. As currently implemented, relative date formatting only
jpayne@69 557 * affects a limited range of calendar days before or after the
jpayne@69 558 * current date, based on the CLDR &lt;field type="day"&gt;/&lt;relative&gt; data:
jpayne@69 559 * For example, in English, "Yesterday", "Today", and "Tomorrow".
jpayne@69 560 * Outside of this range, dates are formatted using the corresponding
jpayne@69 561 * non-relative style.
jpayne@69 562 * @param aLocale The given locale.
jpayne@69 563 * @return A date formatter which the caller owns.
jpayne@69 564 * @stable ICU 2.0
jpayne@69 565 */
jpayne@69 566 static DateFormat* U_EXPORT2 createDateInstance(EStyle style = kDefault,
jpayne@69 567 const Locale& aLocale = Locale::getDefault());
jpayne@69 568
jpayne@69 569 /**
jpayne@69 570 * Creates a date/time formatter with the given formatting styles for the
jpayne@69 571 * given locale.
jpayne@69 572 *
jpayne@69 573 * @param dateStyle The given formatting style for the date portion of the result.
jpayne@69 574 * For example, SHORT for "M/d/yy" in the US locale. As currently
jpayne@69 575 * implemented, relative date formatting only affects a limited range
jpayne@69 576 * of calendar days before or after the current date, based on the
jpayne@69 577 * CLDR &lt;field type="day"&gt;/&lt;relative&gt; data: For example, in English,
jpayne@69 578 * "Yesterday", "Today", and "Tomorrow". Outside of this range, dates
jpayne@69 579 * are formatted using the corresponding non-relative style.
jpayne@69 580 * @param timeStyle The given formatting style for the time portion of the result.
jpayne@69 581 * For example, SHORT for "h:mm a" in the US locale. Relative
jpayne@69 582 * time styles are not currently supported.
jpayne@69 583 * @param aLocale The given locale.
jpayne@69 584 * @return A date/time formatter which the caller owns.
jpayne@69 585 * @stable ICU 2.0
jpayne@69 586 */
jpayne@69 587 static DateFormat* U_EXPORT2 createDateTimeInstance(EStyle dateStyle = kDefault,
jpayne@69 588 EStyle timeStyle = kDefault,
jpayne@69 589 const Locale& aLocale = Locale::getDefault());
jpayne@69 590
jpayne@69 591 #ifndef U_HIDE_INTERNAL_API
jpayne@69 592 /**
jpayne@69 593 * Returns the best pattern given a skeleton and locale.
jpayne@69 594 * @param locale the locale
jpayne@69 595 * @param skeleton the skeleton
jpayne@69 596 * @param status ICU error returned here
jpayne@69 597 * @return the best pattern.
jpayne@69 598 * @internal For ICU use only.
jpayne@69 599 */
jpayne@69 600 static UnicodeString getBestPattern(
jpayne@69 601 const Locale &locale,
jpayne@69 602 const UnicodeString &skeleton,
jpayne@69 603 UErrorCode &status);
jpayne@69 604 #endif /* U_HIDE_INTERNAL_API */
jpayne@69 605
jpayne@69 606 /**
jpayne@69 607 * Creates a date/time formatter for the given skeleton and
jpayne@69 608 * default locale.
jpayne@69 609 *
jpayne@69 610 * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
jpayne@69 611 * be in any order, and this method uses the locale to
jpayne@69 612 * map the skeleton to a pattern that includes locale
jpayne@69 613 * specific separators with the fields in the appropriate
jpayne@69 614 * order for that locale.
jpayne@69 615 * @param status Any error returned here.
jpayne@69 616 * @return A date/time formatter which the caller owns.
jpayne@69 617 * @stable ICU 55
jpayne@69 618 */
jpayne@69 619 static DateFormat* U_EXPORT2 createInstanceForSkeleton(
jpayne@69 620 const UnicodeString& skeleton,
jpayne@69 621 UErrorCode &status);
jpayne@69 622
jpayne@69 623 /**
jpayne@69 624 * Creates a date/time formatter for the given skeleton and locale.
jpayne@69 625 *
jpayne@69 626 * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
jpayne@69 627 * be in any order, and this method uses the locale to
jpayne@69 628 * map the skeleton to a pattern that includes locale
jpayne@69 629 * specific separators with the fields in the appropriate
jpayne@69 630 * order for that locale.
jpayne@69 631 * @param locale The given locale.
jpayne@69 632 * @param status Any error returned here.
jpayne@69 633 * @return A date/time formatter which the caller owns.
jpayne@69 634 * @stable ICU 55
jpayne@69 635 */
jpayne@69 636 static DateFormat* U_EXPORT2 createInstanceForSkeleton(
jpayne@69 637 const UnicodeString& skeleton,
jpayne@69 638 const Locale &locale,
jpayne@69 639 UErrorCode &status);
jpayne@69 640
jpayne@69 641 /**
jpayne@69 642 * Creates a date/time formatter for the given skeleton and locale.
jpayne@69 643 *
jpayne@69 644 * @param calendarToAdopt the calendar returned DateFormat is to use.
jpayne@69 645 * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
jpayne@69 646 * be in any order, and this method uses the locale to
jpayne@69 647 * map the skeleton to a pattern that includes locale
jpayne@69 648 * specific separators with the fields in the appropriate
jpayne@69 649 * order for that locale.
jpayne@69 650 * @param locale The given locale.
jpayne@69 651 * @param status Any error returned here.
jpayne@69 652 * @return A date/time formatter which the caller owns.
jpayne@69 653 * @stable ICU 55
jpayne@69 654 */
jpayne@69 655 static DateFormat* U_EXPORT2 createInstanceForSkeleton(
jpayne@69 656 Calendar *calendarToAdopt,
jpayne@69 657 const UnicodeString& skeleton,
jpayne@69 658 const Locale &locale,
jpayne@69 659 UErrorCode &status);
jpayne@69 660
jpayne@69 661
jpayne@69 662 /**
jpayne@69 663 * Gets the set of locales for which DateFormats are installed.
jpayne@69 664 * @param count Filled in with the number of locales in the list that is returned.
jpayne@69 665 * @return the set of locales for which DateFormats are installed. The caller
jpayne@69 666 * does NOT own this list and must not delete it.
jpayne@69 667 * @stable ICU 2.0
jpayne@69 668 */
jpayne@69 669 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
jpayne@69 670
jpayne@69 671 /**
jpayne@69 672 * Returns whether both date/time parsing in the encapsulated Calendar object and DateFormat whitespace &
jpayne@69 673 * numeric processing is lenient.
jpayne@69 674 * @stable ICU 2.0
jpayne@69 675 */
jpayne@69 676 virtual UBool isLenient(void) const;
jpayne@69 677
jpayne@69 678 /**
jpayne@69 679 * Specifies whether date/time parsing is to be lenient. With
jpayne@69 680 * lenient parsing, the parser may use heuristics to interpret inputs that
jpayne@69 681 * do not precisely match this object's format. Without lenient parsing,
jpayne@69 682 * inputs must match this object's format more closely.
jpayne@69 683 *
jpayne@69 684 * Note: ICU 53 introduced finer grained control of leniency (and added
jpayne@69 685 * new control points) making the preferred method a combination of
jpayne@69 686 * setCalendarLenient() & setBooleanAttribute() calls.
jpayne@69 687 * This method supports prior functionality but may not support all
jpayne@69 688 * future leniency control & behavior of DateFormat. For control of pre 53 leniency,
jpayne@69 689 * Calendar and DateFormat whitespace & numeric tolerance, this method is safe to
jpayne@69 690 * use. However, mixing leniency control via this method and modification of the
jpayne@69 691 * newer attributes via setBooleanAttribute() may produce undesirable
jpayne@69 692 * results.
jpayne@69 693 *
jpayne@69 694 * @param lenient True specifies date/time interpretation to be lenient.
jpayne@69 695 * @see Calendar::setLenient
jpayne@69 696 * @stable ICU 2.0
jpayne@69 697 */
jpayne@69 698 virtual void setLenient(UBool lenient);
jpayne@69 699
jpayne@69 700
jpayne@69 701 /**
jpayne@69 702 * Returns whether date/time parsing in the encapsulated Calendar object processing is lenient.
jpayne@69 703 * @stable ICU 53
jpayne@69 704 */
jpayne@69 705 virtual UBool isCalendarLenient(void) const;
jpayne@69 706
jpayne@69 707
jpayne@69 708 /**
jpayne@69 709 * Specifies whether encapsulated Calendar date/time parsing is to be lenient. With
jpayne@69 710 * lenient parsing, the parser may use heuristics to interpret inputs that
jpayne@69 711 * do not precisely match this object's format. Without lenient parsing,
jpayne@69 712 * inputs must match this object's format more closely.
jpayne@69 713 * @param lenient when true, parsing is lenient
jpayne@69 714 * @see com.ibm.icu.util.Calendar#setLenient
jpayne@69 715 * @stable ICU 53
jpayne@69 716 */
jpayne@69 717 virtual void setCalendarLenient(UBool lenient);
jpayne@69 718
jpayne@69 719
jpayne@69 720 /**
jpayne@69 721 * Gets the calendar associated with this date/time formatter.
jpayne@69 722 * The calendar is owned by the formatter and must not be modified.
jpayne@69 723 * Also, the calendar does not reflect the results of a parse operation.
jpayne@69 724 * To parse to a calendar, use {@link #parse(const UnicodeString&, Calendar& cal, ParsePosition&) const parse(const UnicodeString&, Calendar& cal, ParsePosition&)}
jpayne@69 725 * @return the calendar associated with this date/time formatter.
jpayne@69 726 * @stable ICU 2.0
jpayne@69 727 */
jpayne@69 728 virtual const Calendar* getCalendar(void) const;
jpayne@69 729
jpayne@69 730 /**
jpayne@69 731 * Set the calendar to be used by this date format. Initially, the default
jpayne@69 732 * calendar for the specified or default locale is used. The caller should
jpayne@69 733 * not delete the Calendar object after it is adopted by this call.
jpayne@69 734 * Adopting a new calendar will change to the default symbols.
jpayne@69 735 *
jpayne@69 736 * @param calendarToAdopt Calendar object to be adopted.
jpayne@69 737 * @stable ICU 2.0
jpayne@69 738 */
jpayne@69 739 virtual void adoptCalendar(Calendar* calendarToAdopt);
jpayne@69 740
jpayne@69 741 /**
jpayne@69 742 * Set the calendar to be used by this date format. Initially, the default
jpayne@69 743 * calendar for the specified or default locale is used.
jpayne@69 744 *
jpayne@69 745 * @param newCalendar Calendar object to be set.
jpayne@69 746 * @stable ICU 2.0
jpayne@69 747 */
jpayne@69 748 virtual void setCalendar(const Calendar& newCalendar);
jpayne@69 749
jpayne@69 750
jpayne@69 751 /**
jpayne@69 752 * Gets the number formatter which this date/time formatter uses to format
jpayne@69 753 * and parse the numeric portions of the pattern.
jpayne@69 754 * @return the number formatter which this date/time formatter uses.
jpayne@69 755 * @stable ICU 2.0
jpayne@69 756 */
jpayne@69 757 virtual const NumberFormat* getNumberFormat(void) const;
jpayne@69 758
jpayne@69 759 /**
jpayne@69 760 * Allows you to set the number formatter. The caller should
jpayne@69 761 * not delete the NumberFormat object after it is adopted by this call.
jpayne@69 762 * @param formatToAdopt NumberFormat object to be adopted.
jpayne@69 763 * @stable ICU 2.0
jpayne@69 764 */
jpayne@69 765 virtual void adoptNumberFormat(NumberFormat* formatToAdopt);
jpayne@69 766
jpayne@69 767 /**
jpayne@69 768 * Allows you to set the number formatter.
jpayne@69 769 * @param newNumberFormat NumberFormat object to be set.
jpayne@69 770 * @stable ICU 2.0
jpayne@69 771 */
jpayne@69 772 virtual void setNumberFormat(const NumberFormat& newNumberFormat);
jpayne@69 773
jpayne@69 774 /**
jpayne@69 775 * Returns a reference to the TimeZone used by this DateFormat's calendar.
jpayne@69 776 * @return the time zone associated with the calendar of DateFormat.
jpayne@69 777 * @stable ICU 2.0
jpayne@69 778 */
jpayne@69 779 virtual const TimeZone& getTimeZone(void) const;
jpayne@69 780
jpayne@69 781 /**
jpayne@69 782 * Sets the time zone for the calendar of this DateFormat object. The caller
jpayne@69 783 * no longer owns the TimeZone object and should not delete it after this call.
jpayne@69 784 * @param zoneToAdopt the TimeZone to be adopted.
jpayne@69 785 * @stable ICU 2.0
jpayne@69 786 */
jpayne@69 787 virtual void adoptTimeZone(TimeZone* zoneToAdopt);
jpayne@69 788
jpayne@69 789 /**
jpayne@69 790 * Sets the time zone for the calendar of this DateFormat object.
jpayne@69 791 * @param zone the new time zone.
jpayne@69 792 * @stable ICU 2.0
jpayne@69 793 */
jpayne@69 794 virtual void setTimeZone(const TimeZone& zone);
jpayne@69 795
jpayne@69 796 /**
jpayne@69 797 * Set a particular UDisplayContext value in the formatter, such as
jpayne@69 798 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
jpayne@69 799 * @param value The UDisplayContext value to set.
jpayne@69 800 * @param status Input/output status. If at entry this indicates a failure
jpayne@69 801 * status, the function will do nothing; otherwise this will be
jpayne@69 802 * updated with any new status from the function.
jpayne@69 803 * @stable ICU 53
jpayne@69 804 */
jpayne@69 805 virtual void setContext(UDisplayContext value, UErrorCode& status);
jpayne@69 806
jpayne@69 807 /**
jpayne@69 808 * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
jpayne@69 809 * such as UDISPCTX_TYPE_CAPITALIZATION.
jpayne@69 810 * @param type The UDisplayContextType whose value to return
jpayne@69 811 * @param status Input/output status. If at entry this indicates a failure
jpayne@69 812 * status, the function will do nothing; otherwise this will be
jpayne@69 813 * updated with any new status from the function.
jpayne@69 814 * @return The UDisplayContextValue for the specified type.
jpayne@69 815 * @stable ICU 53
jpayne@69 816 */
jpayne@69 817 virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
jpayne@69 818
jpayne@69 819 /**
jpayne@69 820 * Sets an boolean attribute on this DateFormat.
jpayne@69 821 * May return U_UNSUPPORTED_ERROR if this instance does not support
jpayne@69 822 * the specified attribute.
jpayne@69 823 * @param attr the attribute to set
jpayne@69 824 * @param newvalue new value
jpayne@69 825 * @param status the error type
jpayne@69 826 * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) )
jpayne@69 827 * @stable ICU 53
jpayne@69 828 */
jpayne@69 829
jpayne@69 830 virtual DateFormat& U_EXPORT2 setBooleanAttribute(UDateFormatBooleanAttribute attr,
jpayne@69 831 UBool newvalue,
jpayne@69 832 UErrorCode &status);
jpayne@69 833
jpayne@69 834 /**
jpayne@69 835 * Returns a boolean from this DateFormat
jpayne@69 836 * May return U_UNSUPPORTED_ERROR if this instance does not support
jpayne@69 837 * the specified attribute.
jpayne@69 838 * @param attr the attribute to set
jpayne@69 839 * @param status the error type
jpayne@69 840 * @return the attribute value. Undefined if there is an error.
jpayne@69 841 * @stable ICU 53
jpayne@69 842 */
jpayne@69 843 virtual UBool U_EXPORT2 getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &status) const;
jpayne@69 844
jpayne@69 845 protected:
jpayne@69 846 /**
jpayne@69 847 * Default constructor. Creates a DateFormat with no Calendar or NumberFormat
jpayne@69 848 * associated with it. This constructor depends on the subclasses to fill in
jpayne@69 849 * the calendar and numberFormat fields.
jpayne@69 850 * @stable ICU 2.0
jpayne@69 851 */
jpayne@69 852 DateFormat();
jpayne@69 853
jpayne@69 854 /**
jpayne@69 855 * Copy constructor.
jpayne@69 856 * @stable ICU 2.0
jpayne@69 857 */
jpayne@69 858 DateFormat(const DateFormat&);
jpayne@69 859
jpayne@69 860 /**
jpayne@69 861 * Default assignment operator.
jpayne@69 862 * @stable ICU 2.0
jpayne@69 863 */
jpayne@69 864 DateFormat& operator=(const DateFormat&);
jpayne@69 865
jpayne@69 866 /**
jpayne@69 867 * The calendar that DateFormat uses to produce the time field values needed
jpayne@69 868 * to implement date/time formatting. Subclasses should generally initialize
jpayne@69 869 * this to the default calendar for the locale associated with this DateFormat.
jpayne@69 870 * @stable ICU 2.4
jpayne@69 871 */
jpayne@69 872 Calendar* fCalendar;
jpayne@69 873
jpayne@69 874 /**
jpayne@69 875 * The number formatter that DateFormat uses to format numbers in dates and
jpayne@69 876 * times. Subclasses should generally initialize this to the default number
jpayne@69 877 * format for the locale associated with this DateFormat.
jpayne@69 878 * @stable ICU 2.4
jpayne@69 879 */
jpayne@69 880 NumberFormat* fNumberFormat;
jpayne@69 881
jpayne@69 882
jpayne@69 883 private:
jpayne@69 884
jpayne@69 885 /**
jpayne@69 886 * Gets the date/time formatter with the given formatting styles for the
jpayne@69 887 * given locale.
jpayne@69 888 * @param dateStyle the given date formatting style.
jpayne@69 889 * @param timeStyle the given time formatting style.
jpayne@69 890 * @param inLocale the given locale.
jpayne@69 891 * @return a date/time formatter, or 0 on failure.
jpayne@69 892 */
jpayne@69 893 static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, const Locale& inLocale);
jpayne@69 894
jpayne@69 895
jpayne@69 896 /**
jpayne@69 897 * enum set of active boolean attributes for this instance
jpayne@69 898 */
jpayne@69 899 EnumSet<UDateFormatBooleanAttribute, 0, UDAT_BOOLEAN_ATTRIBUTE_COUNT> fBoolFlags;
jpayne@69 900
jpayne@69 901
jpayne@69 902 UDisplayContext fCapitalizationContext;
jpayne@69 903 friend class DateFmtKeyByStyle;
jpayne@69 904
jpayne@69 905 public:
jpayne@69 906 #ifndef U_HIDE_OBSOLETE_API
jpayne@69 907 /**
jpayne@69 908 * Field selector for FieldPosition for DateFormat fields.
jpayne@69 909 * @obsolete ICU 3.4 use UDateFormatField instead, since this API will be
jpayne@69 910 * removed in that release
jpayne@69 911 */
jpayne@69 912 enum EField
jpayne@69 913 {
jpayne@69 914 // Obsolete; use UDateFormatField instead
jpayne@69 915 kEraField = UDAT_ERA_FIELD,
jpayne@69 916 kYearField = UDAT_YEAR_FIELD,
jpayne@69 917 kMonthField = UDAT_MONTH_FIELD,
jpayne@69 918 kDateField = UDAT_DATE_FIELD,
jpayne@69 919 kHourOfDay1Field = UDAT_HOUR_OF_DAY1_FIELD,
jpayne@69 920 kHourOfDay0Field = UDAT_HOUR_OF_DAY0_FIELD,
jpayne@69 921 kMinuteField = UDAT_MINUTE_FIELD,
jpayne@69 922 kSecondField = UDAT_SECOND_FIELD,
jpayne@69 923 kMillisecondField = UDAT_FRACTIONAL_SECOND_FIELD,
jpayne@69 924 kDayOfWeekField = UDAT_DAY_OF_WEEK_FIELD,
jpayne@69 925 kDayOfYearField = UDAT_DAY_OF_YEAR_FIELD,
jpayne@69 926 kDayOfWeekInMonthField = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
jpayne@69 927 kWeekOfYearField = UDAT_WEEK_OF_YEAR_FIELD,
jpayne@69 928 kWeekOfMonthField = UDAT_WEEK_OF_MONTH_FIELD,
jpayne@69 929 kAmPmField = UDAT_AM_PM_FIELD,
jpayne@69 930 kHour1Field = UDAT_HOUR1_FIELD,
jpayne@69 931 kHour0Field = UDAT_HOUR0_FIELD,
jpayne@69 932 kTimezoneField = UDAT_TIMEZONE_FIELD,
jpayne@69 933 kYearWOYField = UDAT_YEAR_WOY_FIELD,
jpayne@69 934 kDOWLocalField = UDAT_DOW_LOCAL_FIELD,
jpayne@69 935 kExtendedYearField = UDAT_EXTENDED_YEAR_FIELD,
jpayne@69 936 kJulianDayField = UDAT_JULIAN_DAY_FIELD,
jpayne@69 937 kMillisecondsInDayField = UDAT_MILLISECONDS_IN_DAY_FIELD,
jpayne@69 938
jpayne@69 939 // Obsolete; use UDateFormatField instead
jpayne@69 940 ERA_FIELD = UDAT_ERA_FIELD,
jpayne@69 941 YEAR_FIELD = UDAT_YEAR_FIELD,
jpayne@69 942 MONTH_FIELD = UDAT_MONTH_FIELD,
jpayne@69 943 DATE_FIELD = UDAT_DATE_FIELD,
jpayne@69 944 HOUR_OF_DAY1_FIELD = UDAT_HOUR_OF_DAY1_FIELD,
jpayne@69 945 HOUR_OF_DAY0_FIELD = UDAT_HOUR_OF_DAY0_FIELD,
jpayne@69 946 MINUTE_FIELD = UDAT_MINUTE_FIELD,
jpayne@69 947 SECOND_FIELD = UDAT_SECOND_FIELD,
jpayne@69 948 MILLISECOND_FIELD = UDAT_FRACTIONAL_SECOND_FIELD,
jpayne@69 949 DAY_OF_WEEK_FIELD = UDAT_DAY_OF_WEEK_FIELD,
jpayne@69 950 DAY_OF_YEAR_FIELD = UDAT_DAY_OF_YEAR_FIELD,
jpayne@69 951 DAY_OF_WEEK_IN_MONTH_FIELD = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
jpayne@69 952 WEEK_OF_YEAR_FIELD = UDAT_WEEK_OF_YEAR_FIELD,
jpayne@69 953 WEEK_OF_MONTH_FIELD = UDAT_WEEK_OF_MONTH_FIELD,
jpayne@69 954 AM_PM_FIELD = UDAT_AM_PM_FIELD,
jpayne@69 955 HOUR1_FIELD = UDAT_HOUR1_FIELD,
jpayne@69 956 HOUR0_FIELD = UDAT_HOUR0_FIELD,
jpayne@69 957 TIMEZONE_FIELD = UDAT_TIMEZONE_FIELD
jpayne@69 958 };
jpayne@69 959 #endif /* U_HIDE_OBSOLETE_API */
jpayne@69 960 };
jpayne@69 961
jpayne@69 962 U_NAMESPACE_END
jpayne@69 963
jpayne@69 964 #endif /* #if !UCONFIG_NO_FORMATTING */
jpayne@69 965
jpayne@69 966 #endif /* U_SHOW_CPLUSPLUS_API */
jpayne@69 967
jpayne@69 968 #endif // _DATEFMT
jpayne@69 969 //eof