in src/vswhere.lib/Formatter.cpp [144:192]
wstring Formatter::FormatDate(_In_ const FILETIME& value)
{
SYSTEMTIME stUniversal = {};
SYSTEMTIME stLocal = {};
wstring date;
wstring time;
if (!::FileTimeToSystemTime(&value, &stUniversal))
{
throw win32_error();
}
if (!::SystemTimeToTzSpecificLocalTime(NULL, &stUniversal, &stLocal))
{
throw win32_error();
}
// Format date
auto cch = ::GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &stLocal, NULL, NULL, 0);
if (!cch)
{
throw win32_error();
}
date.reserve(cch);
date.resize(cch - 1);
cch = ::GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &stLocal, NULL, const_cast<LPWSTR>(date.c_str()), cch);
if (!cch)
{
throw win32_error();
}
// Format time
cch = ::GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &stLocal, NULL, NULL, 0);
if (!cch)
{
throw win32_error();
}
time.reserve(cch);
time.resize(cch - 1);
cch = ::GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &stLocal, NULL, const_cast<LPWSTR>(time.c_str()), cch);
if (!cch)
{
throw win32_error();
}
return date + L" " + time;
}