Previous Page
Next Page

wcsftime

Generates a formatted wide string of time and date information

#include <time.h>
#include <wchar.h>
size_t wcsftime ( wchar_t * restrict s , size_t n ,
                 const wchar_t * restrict format ,
                 const struct tm * restrict timeptr  );

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

strftime( ), setlocale( )


Previous Page
Next Page