Reputation: 101
Why does the following code output a negative number?
coliru link to see and compile the code yourself.
#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;
}
Output:
Now: -4818978774392359625
Upvotes: 10
Views: 1289
Reputation: 36379
The epoch for libstdc++'s std::filesystem::file_time_type::clock()
appears to be 2174-01-01 00:00:00 UTC therefore a negative count for current dates is not unexpected.
Upvotes: 11