function
<cwchar>

wcsftime

size_t wcsftime (wchar_t* ptr, size_t maxsize, const wchar_t* format,                 const struct tm* timeptr);
Format time as wide string
Copies into ptr the content of format, expanding its format tags into the corresponding values as specified by timeptr, with a limit of maxsize characters.

This is the wide character equivalent of strftime (<ctime>).

Parameters

ptr
Pointer to the destination array where the resulting C wide string is copied.
maxsize
Maximum number of wide characters to be copied to ptr.
format
C wide string that contains a format string that follows the same specifications as format in strftime (see strftime for details).
timeptr
Pointer to a tm structure that contains a calendar time broken down into its components (see struct tm).

Return Value

If the resulting C wide string fits in less than maxsize wide characters including the terminating null wide character, the total number of characters copied to ptr (not including the terminating null wide character) is returned.
Otherwise, zero is returned and the contents of the array are indeterminate.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* wcsftime example */
#include <wchar.h>
#include <time.h>

int main ()
{
  time_t rawtime;
  struct tm * timeinfo;
  wchar_t buffer [80];

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );

  wcsftime (buffer,80,L"Now it's %I:%M%p.",timeinfo);
  wprintf (L"%ls\n",buffer);

  return 0;
}

Example output:

Now it's 04:33PM.


See also