1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-05-02 13:03:52 +00:00

Check rv of localtime_r

This commit is contained in:
gabime 2024-01-13 19:07:36 +02:00
parent ce3922cff1
commit 91bf60a316

View File

@ -84,14 +84,14 @@ spdlog::log_clock::time_point now() noexcept {
#endif #endif
} }
std::tm localtime(const std::time_t &time_tt) noexcept { std::tm localtime(const std::time_t &time_tt) noexcept {
std::tm* rv;
std::tm tm;
#ifdef _WIN32 #ifdef _WIN32
std::tm tm; rv = ::localtime_s(&tm, &time_tt);
::localtime_s(&tm, &time_tt);
#else #else
std::tm tm; rv = ::localtime_r(&time_tt, &tm);
::localtime_r(&time_tt, &tm);
#endif #endif
return tm; return rv != nullptr ? tm : std::tm{};
} }
std::tm localtime() noexcept { std::tm localtime() noexcept {