mirror of https://github.com/stenzek/duckstation
Common: Add helper for thread-safe localtime()
And use it with fmt instead of fmt::localtime.pull/3568/head
parent
aa929370ba
commit
ae77a82ba3
@ -0,0 +1,21 @@
|
||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace Common {
|
||||
|
||||
inline std::tm LocalTime(std::time_t tvalue)
|
||||
{
|
||||
std::tm ttime;
|
||||
#ifdef _MSC_VER
|
||||
localtime_s(&ttime, &tvalue);
|
||||
#else
|
||||
localtime_r(&tvalue, &ttime);
|
||||
#endif
|
||||
return ttime;
|
||||
}
|
||||
|
||||
} // namespace Common
|
||||
Loading…
Reference in New Issue