|
|
|
@ -1,8 +1,15 @@
|
|
|
|
|
#ifndef OPENMW_COMPONENTS_MISC_TIMECONVERT_H
|
|
|
|
|
#define OPENMW_COMPONENTS_MISC_TIMECONVERT_H
|
|
|
|
|
|
|
|
|
|
#include <cerrno>
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <system_error>
|
|
|
|
|
|
|
|
|
|
namespace Misc
|
|
|
|
|
{
|
|
|
|
@ -22,9 +29,11 @@ namespace Misc
|
|
|
|
|
{
|
|
|
|
|
tm time_info{};
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
(void)localtime_s(&time_info, &tp);
|
|
|
|
|
if (const errno_t error = localtime_s(&time_info, &tp); error != 0)
|
|
|
|
|
throw std::system_error(error, std::generic_category());
|
|
|
|
|
#else
|
|
|
|
|
(void)localtime_r(&tp, &time_info);
|
|
|
|
|
if (localtime_r(&tp, &time_info) == nullptr)
|
|
|
|
|
throw std::system_error(errno, std::generic_category());
|
|
|
|
|
#endif
|
|
|
|
|
std::stringstream out;
|
|
|
|
|
out << std::put_time(&time_info, fmt);
|
|
|
|
|