From 6c799d04f8d593bbe2eff7548172a5d8ab7f79eb Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sat, 13 Jan 2024 20:20:58 +0200 Subject: [PATCH] Fix localtime_s()usage --- src/details/os.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/details/os.cpp b/src/details/os.cpp index 94356c76..790a2217 100644 --- a/src/details/os.cpp +++ b/src/details/os.cpp @@ -86,12 +86,13 @@ spdlog::log_clock::time_point now() noexcept { std::tm localtime(const std::time_t &time_tt) noexcept { #ifdef _WIN32 std::tm tm; - const auto *rv = ::localtime_s(&tm, &time_tt); + const auto rv = ::localtime_s(&tm, &time_tt); + return rv == 0 ? tm : std::tm{}; #else std::tm tm; const auto *rv = ::localtime_r(&time_tt, &tm); -#endif return rv != nullptr ? tm : std::tm{}; +#endif } std::tm localtime() noexcept {