diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2018-10-28 23:58:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-28 23:58:17 +0100 |
| commit | 7094f225d424267c22655c0bb765337d7bf13987 (patch) | |
| tree | 885fed1029df854fbaa5bf5aaa60d7ac8a7002ff /Source/Core/Common/Timer.cpp | |
| parent | 2bbc9d40f0a47feba31fe6fdef77361103662f50 (diff) | |
| parent | 5718b870d1793afaf60944dfc1b086d370389538 (diff) | |
Merge pull request #7515 from JosJuice/wcsftime
Use wcsftime instead of strftime on Windows to fix encoding errors
Diffstat (limited to 'Source/Core/Common/Timer.cpp')
| -rw-r--r-- | Source/Core/Common/Timer.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 081dd2008c..1d25cc0f71 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -7,6 +7,8 @@ #include <string> #ifdef _WIN32 +#include <cwchar> + #include <windows.h> #include <mmsystem.h> #include <sys/timeb.h> @@ -203,14 +205,19 @@ std::string Timer::GetTimeFormatted() struct tm* gmTime = localtime(&sysTime); +#ifdef _WIN32 + wchar_t tmp[13]; + wcsftime(tmp, 6, L"%M:%S", gmTime); +#else char tmp[13]; strftime(tmp, 6, "%M:%S", gmTime); +#endif // Now tack on the milliseconds #ifdef _WIN32 struct timeb tp; (void)::ftime(&tp); - return StringFromFormat("%s:%03i", tmp, tp.millitm); + return UTF16ToUTF8(tmp) + StringFromFormat(":%03i", tp.millitm); #elif defined __APPLE__ struct timeval t; (void)gettimeofday(&t, nullptr); @@ -265,9 +272,15 @@ std::string Timer::GetDateTimeFormatted(double time) time_t seconds = (time_t)time + DOUBLE_TIME_OFFSET; tm* localTime = localtime(&seconds); +#ifdef _WIN32 + wchar_t tmp[32] = {}; + wcsftime(tmp, sizeof(tmp), L"%x %X", localTime); + return UTF16ToUTF8(tmp); +#else char tmp[32] = {}; strftime(tmp, sizeof(tmp), "%x %X", localTime); return tmp; +#endif } } // Namespace Common |
