gcc9

How to convert `std::filesystem::file_time_type` to a string using GCC 9

不羁岁月 提交于 2020-06-10 19:46:51
问题 I'm trying to format the modification time of a file as a string (UTC). The following code compiles with GCC 8, but not GCC 9. #include <chrono> #include <filesystem> #include <iomanip> #include <iostream> #include <sstream> namespace fs = std::filesystem; int main() { fs::file_time_type file_time = fs::last_write_time(__FILE__); std::time_t tt = decltype(file_time)::clock::to_time_t(file_time); std::tm *gmt = std::gmtime(&tt); std::stringstream buffer; buffer << std::put_time(gmt, "%A, %d %B

How to convert `std::filesystem::file_time_type` to a string using GCC 9

坚强是说给别人听的谎言 提交于 2020-06-10 19:45:52
问题 I'm trying to format the modification time of a file as a string (UTC). The following code compiles with GCC 8, but not GCC 9. #include <chrono> #include <filesystem> #include <iomanip> #include <iostream> #include <sstream> namespace fs = std::filesystem; int main() { fs::file_time_type file_time = fs::last_write_time(__FILE__); std::time_t tt = decltype(file_time)::clock::to_time_t(file_time); std::tm *gmt = std::gmtime(&tt); std::stringstream buffer; buffer << std::put_time(gmt, "%A, %d %B