From fd7df2ccae4ef18e8fdcf3dcf369c8f2ff185825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 15 Oct 2021 22:49:13 +0200 Subject: [PATCH] Use fmt::localtime instead of thread-unsafe std::localtime fmt::localtime is also less awkward to use compared to std::localtime. --- Source/Core/AudioCommon/AudioCommon.cpp | 2 +- Source/Core/Common/SettingsHandler.cpp | 2 +- Source/Core/Core/Core.cpp | 2 +- Source/Core/VideoCommon/FrameDump.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index 65b5f92ed4..ffefe59529 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -210,7 +210,7 @@ void StartAudioDump() std::string path_prefix = File::GetUserPath(D_DUMPAUDIO_IDX) + SConfig::GetInstance().GetGameID(); std::string base_name = - fmt::format("{}_{:%Y-%m-%d_%H-%M-%S}", path_prefix, *std::localtime(&start_time)); + fmt::format("{}_{:%Y-%m-%d_%H-%M-%S}", path_prefix, fmt::localtime(start_time)); const std::string audio_file_name_dtk = fmt::format("{}_dtkdump.wav", base_name); const std::string audio_file_name_dsp = fmt::format("{}_dspdump.wav", base_name); diff --git a/Source/Core/Common/SettingsHandler.cpp b/Source/Core/Common/SettingsHandler.cpp index 54e7d1d929..109c80abb8 100644 --- a/Source/Core/Common/SettingsHandler.cpp +++ b/Source/Core/Common/SettingsHandler.cpp @@ -140,6 +140,6 @@ std::string SettingsHandler::GenerateSerialNumber() // Must be 9 characters at most; otherwise the serial number will be rejected by SDK libraries, // as there is a check to ensure the string length is strictly lower than 10. // 3 for %j, 2 for %H, 2 for %M, 2 for %S. - return fmt::format("{:%j%H%M%S}", *std::localtime(&t)); + return fmt::format("{:%j%H%M%S}", fmt::localtime(t)); } } // namespace Common diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 96a3aab34e..378ad9fd74 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -739,7 +739,7 @@ static std::string GenerateScreenshotName() const std::time_t cur_time = std::time(nullptr); const std::string base_name = - fmt::format("{}_{:%Y-%m-%d_%H-%M-%S}", path_prefix, *std::localtime(&cur_time)); + fmt::format("{}_{:%Y-%m-%d_%H-%M-%S}", path_prefix, fmt::localtime(cur_time)); // First try a filename without any suffixes, if already exists then append increasing numbers std::string name = fmt::format("{}.png", base_name); diff --git a/Source/Core/VideoCommon/FrameDump.cpp b/Source/Core/VideoCommon/FrameDump.cpp index ceba863b89..b4eebc7d1a 100644 --- a/Source/Core/VideoCommon/FrameDump.cpp +++ b/Source/Core/VideoCommon/FrameDump.cpp @@ -86,7 +86,7 @@ std::string GetDumpPath(const std::string& extension, std::time_t time, u32 inde File::GetUserPath(D_DUMPFRAMES_IDX) + SConfig::GetInstance().GetGameID(); const std::string base_name = - fmt::format("{}_{:%Y-%m-%d_%H-%M-%S}_{}", path_prefix, *std::localtime(&time), index); + fmt::format("{}_{:%Y-%m-%d_%H-%M-%S}_{}", path_prefix, fmt::localtime(time), index); const std::string path = fmt::format("{}.{}", base_name, extension);