I\'ve created a time point, but I have been struggling to print it to the terminal.
#include
#include
int main(){
//set
Yet another snippet of code. Plus side is that it is fairly standalone and supports microsecond text representation.
std::ostream& operator<<(std::ostream& stream, const std::chrono::system_clock::time_point& point)
{
auto time = std::chrono::system_clock::to_time_t(point);
std::tm* tm = std::localtime(&time);
char buffer[26];
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S.", tm);
stream << buffer;
auto duration = point.time_since_epoch();
auto seconds = std::chrono::duration_cast(duration);
auto remaining = std::chrono::duration_cast(duration - seconds);
// remove microsecond cast line if you would like a higher resolution sub second time representation, then just stream remaining.count()
auto micro = std::chrono::duration_cast(remaining);
return stream << micro.count();
}