I am trying to learn C++ Win32. I built a timer class for a game environment. Typical game timer and it works well. I have this function that I would like to display the current game time with.
std::wstring Time::DisplayGameTime()
{
std::wstring Label = L"Current Time: ";
std::wstring daysText = L" " + std::to_wstring(Days()); //Returns int
std::wstring monthsText = L", " + std::to_wstring(Months()); //Returns int
std::wstring yearsText = L", " + std::to_wstring(Years()); // Returns int
std::wstring hoursText = L" " + std::to_wstring(Hours()); // Returns int
std::wstring minutesText = L" : " + std::to_wstring(Minutes()); // Returns int
std::wstring message = Label + daysText + monthsText + yearsText + hoursText + minutesText;
return message;
}
This works well too, except the minutes integer only prints one digit until it reaches 10. I would like to pad a leading zero to it like you would find in a normal time clock. Since I am using std::to_wstring, I cannot use format specifiers like in a swprintf_s buffer. I have tried to figure out how to use a wstringstream for this but none of what I've tried has worked.
The goal is to use this function to convert to LPCWSTR later on for DrawText to display to the Window.