ICU-863 Documentation fixes

X-SVN-Rev: 5482
This commit is contained in:
George Rhoten 2001-08-16 22:28:14 +00:00
parent 5979c84b75
commit e676f8d380
2 changed files with 86 additions and 48 deletions

View File

@ -43,9 +43,10 @@ class TimeZone;
* methods: * methods:
* <pre> * <pre>
* \code * \code
* DateFormat* dfmt = DateFormat::createDateInstance(); * DateFormat* dfmt = DateFormat::createDateInstance();
* UnicodeString myString; * UDate myDate = Calendar::getNow();
* myString = dfmt->format( myDate, myString ); * UnicodeString myString;
* myString = dfmt->format( myDate, myString );
* \endcode * \endcode
* </pre> * </pre>
* If you are formatting multiple numbers, it is more efficient to get the * If you are formatting multiple numbers, it is more efficient to get the
@ -53,28 +54,40 @@ class TimeZone;
* information about the local language and country conventions multiple times. * information about the local language and country conventions multiple times.
* <pre> * <pre>
* \code * \code
* DateFormat* df = DateFormat::createDateInstance(); * DateFormat* df = DateFormat::createDateInstance();
* UnicodeString myString; * UnicodeString myString;
* UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values * UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
* for (int32_t i = 0; i < 3; ++i) { * for (int32_t i = 0; i < 3; ++i) {
* myString.remove(); * myString.remove();
* cout << df->format( myDateArr[i], myString ) << endl; * cout << df->format( myDateArr[i], myString ) << endl;
* } * }
* \endcode
* </pre>
* To get specific fields of a date, you can use UFieldPosition to
* get specific fields.
* <pre>
* \code
* DateFormat* dfmt = DateFormat::createDateInstance();
* FieldPosition pos(DateFormat::YEAR_FIELD);
* UnicodeString myString;
* myString = dfmt->format( myDate, myString );
* cout << myString << endl;
* cout << pos.getBeginIndex() << "," << pos. getEndIndex() << endl;
* \endcode * \endcode
* </pre> * </pre>
* To format a date for a different Locale, specify it in the call to * To format a date for a different Locale, specify it in the call to
* getDateInstance(). * createDateInstance().
* <pre> * <pre>
* \code * \code
* DateFormat* df = * DateFormat* df =
* DateFormat::createDateInstance( DateFormat::SHORT, Locale::FRANCE); * DateFormat::createDateInstance( DateFormat::SHORT, Locale::getFrance());
* \endcode * \endcode
* </pre> * </pre>
* You can use a DateFormat to parse also. * You can use a DateFormat to parse also.
* <pre> * <pre>
* \code * \code
* UErrorCode status = U_ZERO_ERROR; * UErrorCode status = U_ZERO_ERROR;
* UDate myDate = df->parse(myString, status); * UDate myDate = df->parse(myString, status);
* \endcode * \endcode
* </pre> * </pre>
* Use createDateInstance() to produce the normal date format for that country. * Use createDateInstance() to produce the normal date format for that country.

View File

@ -32,16 +32,16 @@
* use one of the static factory methods: * use one of the static factory methods:
* <pre> * <pre>
* \code * \code
* UErrorCode status; * UErrorCode status = U_ZERO_ERROR;
* UChar *myString; * UChar *myString;
* int32_t myStrlen=0; * int32_t myStrlen = 0;
* UDateFormat* dfmt = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "PST", &status); * UDateFormat* dfmt = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "PST", &status);
* myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status); * myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status);
* if(status==U_BUFFER_OVERFLOW_ERROR){ * if (status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR; * status=U_ZERO_ERROR;
* myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) ); * myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
* udat_format(dfmt, myDate, myString, myStrlen+1, NULL, &status); * udat_format(dfmt, myDate, myString, myStrlen+1, NULL, &status);
* } * }
* \endcode * \endcode
* </pre> * </pre>
* If you are formatting multiple numbers, it is more efficient to get the * If you are formatting multiple numbers, it is more efficient to get the
@ -49,20 +49,45 @@
* information about the local language and country conventions multiple times. * information about the local language and country conventions multiple times.
* <pre> * <pre>
* \code * \code
* int32_t i, myStrlen=0; * UErrorCode status = U_ZERO_ERROR;
* UChar* myString; * int32_t i, myStrlen = 0;
* UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values * UChar* myString;
* UDateFormat* df = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "GMT", &status); * char buffer[1024];
* for (i = 0; i < 3; ++i) { * UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
* myStrlen = udat_format(df, myDate, NULL, myStrlen, &pos, &status); * UDateFormat* df = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "GMT", &status);
* if(status==U_BUFFER_OVERFLOW_ERROR){ * for (i = 0; i < 3; i++) {
* status=U_ZERO_ERROR; * myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status);
* myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) ); * if(status == U_BUFFER_OVERFLOW_ERROR){
* udat_format(df, myDate, myString, myStrlen+1, &pos, &status); * status = U_ZERO_ERROR;
* } * myString = (UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
* printf("%s \n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*) * udat_format(df, myDateArr[i], myString, myStrlen+1, NULL, &status);
* free(myString); * printf("%s\n", u_austrcpy(buffer, myString) );
* } * free(myString);
* }
* }
* \endcode
* </pre>
* To get specific fields of a date, you can use UFieldPosition to
* get specific fields.
* <pre>
* \code
* UErrorCode status = U_ZERO_ERROR;
* UFieldPosition pos;
* UChar *myString;
* int32_t myStrlen = 0;
* char buffer[1024];
*
* pos.field = 1; // Same as the DateFormat::EField enum
* UDateFormat* dfmt = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "PST", &status);
* myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
* if (status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
* udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);
* }
* printf("date format: %s\n", u_austrcpy(buffer, myString));
* buffer[pos.endIndex] = 0; // NULL terminate the string.
* printf("UFieldPosition position equals %s\n", &buffer[pos.beginIndex]);
* \endcode * \endcode
* </pre> * </pre>
* To format a date for a different Locale, specify it in the call to * To format a date for a different Locale, specify it in the call to
@ -75,9 +100,9 @@
* You can use a DateFormat API udat_parse() to parse. * You can use a DateFormat API udat_parse() to parse.
* <pre> * <pre>
* \code * \code
* UErrorCode status = U_ZERO_ERROR; * UErrorCode status = U_ZERO_ERROR;
* int32_t parsepos=0; * int32_t parsepos=0;
* UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status); * UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);
* \endcode * \endcode
* </pre> * </pre>
* You can pass in different options for the arguments for date and time style * You can pass in different options for the arguments for date and time style
@ -131,10 +156,10 @@ typedef enum UDateFormatStyle UDateFormatStyle;
* Open a new UDateFormat for formatting and parsing dates and times. * Open a new UDateFormat for formatting and parsing dates and times.
* A UDateFormat may be used to format dates in calls to \Ref{udat_format}, * A UDateFormat may be used to format dates in calls to \Ref{udat_format},
* and to parse dates in calls to \Ref{udat_parse}. * and to parse dates in calls to \Ref{udat_parse}.
* @param timeStyle The style used to format times; one of UDAT_FULL_STYLE, UDAT_LONG_STYLE, * @param timeStyle The style used to format times; one of UDAT_FULL, UDAT_LONG,
* UDAT_MEDIUM_STYLE, UDAT_SHORT_STYLE, or UDAT_DEFAULT_STYLE * UDAT_MEDIUM, UDAT_SHORT, or UDAT_DEFAULT
* @param dateStyle The style used to format dates; one of UDAT_FULL_STYLE, UDAT_LONG_STYLE, * @param dateStyle The style used to format dates; one of UDAT_FULL, UDAT_LONG,
* UDAT_MEDIUM_STYLE, UDAT_SHORT_STYLE, or UDAT_DEFAULT_STYLE * UDAT_MEDIUM, UDAT_SHORT, or UDAT_DEFAULT
* @param locale The locale specifying the formatting conventions * @param locale The locale specifying the formatting conventions
* @param tzID A timezone ID specifying the timezone to use. If 0, use * @param tzID A timezone ID specifying the timezone to use. If 0, use
* the default timezone. * the default timezone.
@ -149,8 +174,8 @@ U_CAPI UDateFormat*
udat_open(UDateFormatStyle timeStyle, udat_open(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle, UDateFormatStyle dateStyle,
const char *locale, const char *locale,
const UChar *tzID, const UChar *tzID,
int32_t tzIDLength, int32_t tzIDLength,
UErrorCode *status); UErrorCode *status);
/** /**