Name
wcsftime
Synopsis
Generates a formatted wide string of time and date information
#include <time.h> #include <wchar.h> size_twcsftime
( wchar_t * restricts
, size_tn
, const wchar_t * restrictformat
, const struct tm * restricttimeptr
);
The wcsftime()
function is
similar to strftime()
, except
that its format string argument and the output string it generates
are wide character strings. Accordingly, the length
n
and the function’s return value
indicate numbers of wide characters, not byte characters. The
locations that wcsftime()
reads
from and writes to using its restricted pointer parameters must not
overlap.
Example
#define MAX_HDR 1024
time_t now;
struct tm *localnow;
wchar_t hdr_date[MAX_HDR] = L"";
time( &now );
localnow = localtime( &now );
if (wcsftime
( hdr_date, MAX_HDR, L"Date: %a, %d %b %Y %T %z", localnow ) )
fputws( hdr_date, stdout );
else
return -1;
See Also
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.