diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 3b99dd69..f60629be 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -226,14 +226,14 @@ auto get_file_time_now() -> std::uint64_t { void get_local_time_now(struct tm &local_time) { memset(&local_time, 0, sizeof(local_time)); + static std::mutex mtx{}; + mutex_lock lock{mtx}; + const auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); #ifdef _WIN32 localtime_s(&local_time, &now); #else - static std::mutex mtx{}; - mutex_lock lock{mtx}; - const auto *tmp = std::localtime(&now); if (tmp != nullptr) { memcpy(&local_time, tmp, sizeof(local_time));