Formats a date in a localized manner.
int32 intlFormatDate(Item locItem,DateSpec spec,const GregorianDate *date,unichar *result, uint32 resultSize);
This function formats a date according to a template and to the rules specified by the locale item provided. The formatting string works in a manner similar to the way printf()
formatting strings are handled, but uses some specialized format commands tailored to date generation. The following format commands are supported:
%D - day of month
%H - hour using 24-hour style
%h - hour using 12-hour style
%M - minutes
%N - month name
%n - abbreviated month name
%O - month number
%P - AM or PM strings
%S - seconds
%W - weekday name
%w - abbreviated weekday name
%Y - year
In addition to straight format commands, the formatting string can also specify a field width, a field limit, and a field pad character. This is done in a manner identical to the way printf()
formatting strings specify these values. That is
%[flags][width][.limit]command
where flags can be “-” or “0”, width is a positive numeric value, limit is a positive numeric value, and command is one of the format commands mentioned above. Refer to documentation on the standard C printf()
function for more information on how these numbers and flags interact.
A difference with standard printf()
processing is that the limit value is applied starting from the rightmost digits, instead of the leftmost. For example;
%.2Y
Prints the rightmost two digits of the current year.
If positive, then the number of characters in the result buffer. If negative, then an error code. The string copied into the result buffer is guaranteed to be NULL-terminated.
INTL_ERR_BADRESULTBUFFER
The result buffer pointer was NULL or wasn't invalid writable memory.
INTL_ERR_BUFFERTOOSMALL
There was not enough room in the result buffer.
Folio call implemented in international folio V24.
intl.h
intlOpenLocale
(), IntlFormatNumber()