std::wcsftime

Header: <cwchar>

Converts the date and time information from a given calendar time time to a null-terminated wide character string str according to format string format. Up to count wide characters are written.

# Declarations

std::size_t wcsftime( wchar_t* str, std::size_t count, const wchar_t* format, const std::tm* time );

# Parameters

# Return value

Number of wide characters written into the wide character array pointed to by str not including the terminating L’\0’ on success. If count was reached before the entire string could be stored, 0 is returned and the contents are undefined.

# Example

#include <ctime>
#include <cwchar>
#include <iostream>
#include <locale>
 
int main()
{
    std::locale::global(std::locale("ja_JP.utf8"));
    std::time_t t = std::time(nullptr);
    wchar_t wstr[100];
    if (std::wcsftime(wstr, 100, L"%A %c", std::localtime(&t)))
        std::wcout << wstr << '\n';
}

# See also