Time conversions cause exceptions
When I build OpenMW 0.49 locally on machine with Windows 10 1809 and MVSC2022, save loading menu does not display saves screenshots and timestamps.
It throws the "The specified module could not be found." runtime exception (presumably due to missing icu.dll) when it tries to convert timestamps in the timecovert.hpp:
inline std::time_t toTimeT(std::filesystem::file_time_type tp)
{
using namespace std::chrono;
#if __cpp_lib_chrono >= 201907
const auto systemTime = clock_cast<system_clock>(tp); // <- crashes here
#else
auto systemTime = time_point_cast<system_clock::duration>(
tp - std::filesystem::file_time_type::clock::now() + system_clock::now());
#endif
return system_clock::to_time_t(systemTime);
}
If I use such code, it works fine:
inline std::time_t toTimeT(std::filesystem::file_time_type tp)
{
using namespace std::chrono;
auto systemTime = time_point_cast<system_clock::duration>(
tp - std::filesystem::file_time_type::clock::now() + system_clock::now());
return system_clock::to_time_t(systemTime);
}
If I understood correctly, it is because older Windows versions do not support std::chrono::get_tzdb_list(), which is used under hood of clock_cast and requires icu.dll.
Interesting that the issue does not happen with MSVC2019 GitLab builds (probably because __cpp_lib_chrono >= 201907 condition fails). Can not find MSVC2022 builds to test them.
Edited by Andrei Kortunov