diff --git a/components/misc/timeconvert.hpp b/components/misc/timeconvert.hpp index e4e3be35a4..7f012fb4a0 100644 --- a/components/misc/timeconvert.hpp +++ b/components/misc/timeconvert.hpp @@ -1,8 +1,15 @@ #ifndef OPENMW_COMPONENTS_MISC_TIMECONVERT_H #define OPENMW_COMPONENTS_MISC_TIMECONVERT_H +#include #include +#include +#include +#include +#include #include +#include +#include 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);