ICU-2589 docs update

X-SVN-Rev: 12240
This commit is contained in:
Steven R. Loomis 2003-06-03 01:27:18 +00:00
parent 89aff51cad
commit d2cf2037ff
2 changed files with 44 additions and 35 deletions

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2001, International Business Machines Corporation and others. All Rights Reserved.
* Copyright (C) 1996-2003, International Business Machines Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -38,7 +38,7 @@
* UErrorCode status = U_ZERO_ERROR;
* UChar *myString;
* int32_t myStrlen = 0;
* UDateFormat* dfmt = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "PST", &status);
* UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, -1, &status);
* myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status);
* if (status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
@ -57,7 +57,7 @@
* UChar* myString;
* char buffer[1024];
* UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
* UDateFormat* df = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "GMT", &status);
* UDateFormat* df = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, 0, &status);
* for (i = 0; i < 3; i++) {
* myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status);
* if(status == U_BUFFER_OVERFLOW_ERROR){
@ -81,7 +81,7 @@
* char buffer[1024];
*
* pos.field = 1; // Same as the DateFormat::EField enum
* UDateFormat* dfmt = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "PST", &status);
* UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, -1, NULL, 0, &status);
* myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
* if (status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
@ -97,7 +97,7 @@
* udat_open()
* <pre>
* \code
* UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", "GMT", &status);
* UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", NULL, -1, NULL, 0, &status);
* \endcode
* </pre>
* You can use a DateFormat API udat_parse() to parse.
@ -132,10 +132,13 @@
/** A date formatter.
* For usage in C programs.
* @stable ICU 2.6
*/
typedef void* UDateFormat;
/** The possible date/time format styles */
/** The possible date/time format styles
* @stable ICU 2.6
*/
typedef enum UDateFormatStyle {
/** Full style */
UDAT_FULL,
@ -208,7 +211,6 @@ udat_clone(const UDateFormat *fmt,
/**
* Format a date using an UDateFormat.
* The date will be formatted using the conventions specified in \Ref{udat_open}
* or \Ref{udat_openPattern}
* @param format The formatter to use
* @param dateToFormat The date to format
* @param result A pointer to a buffer to receive the formatted number.
@ -235,7 +237,6 @@ udat_format( const UDateFormat* format,
/**
* Parse a string into an date/time using a UDateFormat.
* The date will be parsed using the conventions specified in \Ref{udat_open}
* or \Ref{udat_openPattern}
* @param format The formatter to use.
* @param text The text to parse.
* @param textLength The length of text, or -1 if null-terminated.
@ -256,7 +257,6 @@ udat_parse( const UDateFormat* format,
/**
* Parse a string into an date/time using a UDateFormat.
* The date will be parsed using the conventions specified in \Ref{udat_open}
* or \Ref{udat_openPattern}
* @param format The formatter to use.
* @param calendar The calendar in which to store the parsed data.
* @param text The text to parse.
@ -437,7 +437,10 @@ udat_applyPattern( UDateFormat *format,
const UChar *pattern,
int32_t patternLength);
/** The possible types of date format symbols */
/**
* The possible types of date format symbols
* @stable ICU 2.6
*/
typedef enum UDateFormatSymbolType {
/** The era names, for example AD */
UDAT_ERAS,
@ -458,6 +461,7 @@ typedef enum UDateFormatSymbolType {
struct UDateFormatSymbols;
/** Date format symbols.
* For usage in C programs.
* @stable ICU 2.6
*/
typedef struct UDateFormatSymbols UDateFormatSymbols;

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1997-2001, International Business Machines Corporation and others. All Rights Reserved.
* Copyright (C) 1997-2003, International Business Machines Corporation and others. All Rights Reserved.
* Modification History:
*
* Date Name Description
@ -41,9 +41,9 @@
* \code
* UChar myString[20];
* double myNumber = 7.0;
* UErrorCode success = U_ZERO_ERROR;
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
* unum_formatDouble(nf, myNumber, myString, u_strlen(myString), NULL, &status);
* UErrorCode status = U_ZERO_ERROR;
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status);
* unum_formatDouble(nf, myNumber, myString, 20, NULL, &status);
* printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
* \endcode
* </pre>
@ -53,39 +53,44 @@
* conventions multiple times.
* <pre>
* \code
* UChar* myString;
* int32_t i, resultlength, reslenneeded;
* UErrorCode success = U_ZERO_ERROR;
* int32_t a[] = { 123, 3333, -1234567 };
* const int32_t a_len = sizeof(a) / sizeof(a[0]);
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
* for (i = 0; i < a_len; i++) {
* resultlength=0;
* reslenneeded=unum_format(nf, a[i], NULL, resultlength, NULL, &status);
* if(status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* resultlength=resultlengthneeded+1;
* result=(UChar*)malloc(sizeof(UChar) * resultlength);
* unum_format(nf, a[i], result, resultlength, NULL, &status);
* }
* printf(" Example 2: %s\n", austrdup(result) );
* free(result);
* }
* uint32_t i, resultlength, reslenneeded;
* UErrorCode status = U_ZERO_ERROR;
* UFieldPosition pos;
* uint32_t a[] = { 123, 3333, -1234567 };
* const uint32_t a_len = sizeof(a) / sizeof(a[0]);
* UNumberFormat* nf;
* UChar* result = NULL;
*
* nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status);
* for (i = 0; i < a_len; i++) {
* resultlength=0;
* reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status);
* result = NULL;
* if(status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* resultlength=reslenneeded+1;
* result=(UChar*)malloc(sizeof(UChar) * resultlength);
* unum_format(nf, a[i], result, resultlength, &pos, &status);
* }
* printf( " Example 2: %s\n", austrdup(result));
* free(result);
* }
* \endcode
* </pre>
* To format a number for a different Locale, specify it in the
* call to unum_open().
* <pre>
* \code
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, "fr_FR", &success)
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, "fr_FR", NULL, &success)
* \endcode
* </pre>
* You can use a NumberFormat API unum_parse() to parse.
* <pre>
* \code
* UErrorCode success;
* UErrorCode status = U_ZERO_ERROR;
* int32_t pos=0;
* unum_parse(nf, result, u_strlen(result), &pos, &success);
* int32_t num;
* num = unum_parse(nf, str, u_strlen(str), &pos, &status);
* \endcode
* </pre>
* Use UCAL_DECIMAL to get the normal number format for that country.