jon*_*rox 10 c++ filesystems time c++-chrono
为什么下面的代码会输出负数?
coliru 链接可自行查看和编译代码。
#include <chrono>
#include <filesystem>
#include <iostream>
int main()
{
std::cout << "Now: "
<< std::filesystem::file_time_type::clock().now().time_since_epoch().count()
<< "\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Output:
Now: -4818978774392359625
Run Code Online (Sandbox Code Playgroud)
Ala*_*les 11
libstdc++ 的纪元std::filesystem::file_time_type::clock()似乎是2174-01-01 00:00:00 UTC,因此当前日期的负计数并不意外。