martinzink commented on code in PR #1560: URL: https://github.com/apache/nifi-minifi-cpp/pull/1560#discussion_r1171319182
########## 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: It turns out we can't rely on clock_cast on windows either, because (for some reason it needs timezone information which should be available after msi install but not neccesarly there during tests of course we could load it like CronTests do, but I think we can skip the hassle since the other platforms dont have clock_cast) Anyways, I've refactored these in https://github.com/apache/nifi-minifi-cpp/pull/1560/commits/d8e7f065500dc282786918880057f7a23ca0b942 I've also removed the to_time_t functions from FileUtils since it was only used in a single test (ListFileTests) https://github.com/apache/nifi-minifi-cpp/pull/1560/commits/256d695e88751dbf5519546f53eebb72e4f3776f -- 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