This example shows how to convert a date and time to a Unicode string using
the specified locale object.
#include <stdio.h>
#include <time.h>
#include <unidef.h>
int main(void) {
LocaleObject locale_object = NULL;
struct tm *ptime;
time_t time_date;
UniChar ucs[30];
int max_size = 30;
int elements;
int rc = ULS_SUCCESS;
/*****************************************************************/
/* Assumes LANG environment variable set to a valid locale name, */
/* such as fr_FR */
/*****************************************************************/
rc = UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
(UniChar *)L"", &locale_object);
if (rc != ULS_SUCCESS) {
printf("UniCreateLocaleObject error: return code = %u\n", rc);
return 1;
}
time_date = time(NULL);
ptime = localtime(&time_date);
/* elements contains number of code elements placed into ucs */
elements = UniStrftime(locale_object, ucs,
max_size,
(UniChar *)L"%a %b %d\n %I:%M %p",
ptime);
return (ULS_SUCCESS);
}