In addition to the strftime subroutine defined in the C programming
language standard, XPG4 defines the following time formatting
subroutines:
| wcsftime | Formats time into wide character code strings. |
| strptime | Converts a multibyte string into an internal time format. |
#include <stdio.h>
#include <langinfo.h>
#include <locale.h>
#include <time.h>
main()
{
wchar_t timebuf[BUFSIZE];
time_t clock = time( (time_t*) NULL);
struct tim *tmptr = localetime(&clock);
(void)setlocale(LC_ALL, "");
wcsftime(
timebuf, /* Time string output buffer */
BUFSIZ, /*Maximum size of output string */
nl_langinfo(D_T_FMT), /* Date/time format */
tmptr /* Pointer to tm structure */
);
printf("%S\n", timebuf);
}
#include <langinfo.h>
#include <locale.h>
#include <time.h>
main(int argc, char **argv)
{
struct tm tm;
(void)setlocale(LC_ALL, "");
if (argc != 2) {
... /* Error handling */
}
if (strptime(
argv[1], /* Formatted time string */
nl_langinfo(D_T_FMT), /* Date/time format */
&tm /* Address of tm structure */
) == NULL) {
... /* Error handling */
}
else {
... /* Other Processing */
}
}
National Language Support Subroutines Overview provides information about wide character and multibyte subroutines.
For general information about internationalizing programs, see Chapter 16, National Language Support and Locale Overview for Programming .
The strftime subroutine, strptime subroutine, wcsftime subroutine.