Check rv of localtime_r

pull/3028/head
gabime 2 years ago
parent ce3922cff1
commit 91bf60a316

@ -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 {
#ifdef _WIN32 std::tm* rv;
std::tm tm; std::tm tm;
::localtime_s(&tm, &time_tt); #ifdef _WIN32
rv = ::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 {

Loading…
Cancel
Save