C Standard Libraries C++

wcsftime()

Declaration

size_t wcsftime(wchar_t* wpOutput,
                size_t uiMaxSize,
                const wchar_t* kwpFormat,
                const tm* kqpTimePtr);

Description

This function takes in a time specification through the pointer "kqpTimePtr" and a format request through the argument "kwpFormat" and outputs a text time description in the wide-character array buffer that is passed in as "wpOutput." The argument "uiMaxSize" is the maximum number of characters used in the description and the value returned is the actual length of the text description outputted in "wpOutput."

Example

#include <cwchar>
#include <ctime>

int main()
{
    time_t qTime;
    tm* qpTimeSpec;
    // Get the number of seconds since midnight Jan. 1, 1970
    time(&qTime);
    // Convert the seconds to a tm struct variable
    qpTimeSpec = gmtime(&qTime);

    wchar_t waTime[100];
    size_t uiActualLength = wcsftime(waTime, 100, L"%I:%M %p", qpTimeSpec);
    wprintf(L"Written length = %u\n", uiActualLength);
    wprintf(L"Time = %ws\n", waTime);

    // Keep the window open until "Enter" is pressed
    getwchar();
    return 0;
}

Output

wcsftime() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.