fgerlits commented on code in PR #1560: URL: https://github.com/apache/nifi-minifi-cpp/pull/1560#discussion_r1169704112
########## libminifi/src/utils/file/FileUtils.cpp: ########## @@ -74,13 +74,23 @@ time_t to_time_t(std::filesystem::file_time_type file_time) { #endif } -std::chrono::time_point<std::chrono::system_clock> to_sys(std::filesystem::file_time_type file_time) { -#if defined(WIN32) || defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 14000 - return std::chrono::time_point_cast<std::chrono::system_clock::duration>(file_time - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now()); -#elif defined(_LIBCPP_VERSION) +std::chrono::system_clock::time_point to_sys(std::filesystem::file_time_type file_time) { +#if defined(WIN32) + return std::chrono::clock_cast<std::chrono::system_clock>(file_time); +#elif defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 14000) return std::chrono::system_clock::from_time_t(std::chrono::file_clock::to_time_t(file_time)); #else - return std::chrono::file_clock::to_sys(file_time); + return std::chrono::time_point_cast<std::chrono::system_clock::duration>(std::chrono::file_clock::to_sys(file_time)); +#endif +} + +std::filesystem::file_time_type from_sys(std::chrono::system_clock::time_point sys_time) { +#if defined(WIN32) + return std::chrono::clock_cast<std::chrono::file_clock>(sys_time); +#elif defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 14000) + return std::chrono::file_clock::from_time_t(std::chrono::system_clock::to_time_t(sys_time)); +#else + return std::chrono::file_clock::from_sys(sys_time); Review Comment: Ah, got it. The duration conversion happens automatically in the `return` statement, but we need the `time_point_cast` when converting from a 128-bit underlying type to a 64-bit one (but not the other way round). That's a bit nasty -- I hope `clock_cast` will fix this problem when it's available on all compilers. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org