The incvfmtasc() function
The incvfmtasc() function uses a formatting mask to convert a character string to an interval value.
Syntax
mint incvfmtasc(inbuf, fmtstring, invvalue)
char *inbuf;
char *fmtstring;
intrvl_t *invvalue;
- inbuf
- A pointer to the buffer that contains the string to convert.
- fmtstring
- A pointer to a buffer that contains the formatting mask to use for the inbuf string. This time-formatting mask contains the same formatting directives that the DBTIME environment variable supports. (For a list of these directives, see the description of DBTIME in the Informix® Guide to SQL: Reference).
- invvalue
- A pointer to an initialized interval variable.
Usage
You must initialize the interval variable in invvalue with the qualifier you want this variable to have. The interval variable does not need to specify the same qualifier as the formatting mask. When the interval qualifier is different from the implied formatting-mask qualifier, incvfmtasc() converts the result to appropriate units as necessary. However, both qualifiers must belong to the same interval class: either the year to month class or the day to fraction class.
All fields in the character string in inbuf must be contiguous. In other words, if the qualifier is hour to second, you must specify all values for hour, minute, and second somewhere in the string, or incvfmtasc() returns an error.
The inbuf character string can have leading and trailing spaces. However, from the first significant digit to the last, inbuf can contain only digits and delimiters that are appropriate for the qualifier fields that the formatting mask implies.
If the character string is acceptable, the incvfmtasc() function sets the interval value in invvalue and returns zero. Otherwise, the function returns an error code and the interval variable contains an unpredictable value.
The formatting directives %B, %b, and %p, which the DBTIME environment variable accepts, are not applicable in fmtstring because month name and a.m. and p.m. information is not relevant for intervals of time. Use the %Y directive if the interval is more than 99 years (%y can handle only two digits). For hours, use %H (not %I, because %I can represent only 12 hours). If fmtstring is an empty string, the function returns an error.
Return values
- 0
- The conversion was successful.
- <0
- The conversion failed.