Is there a convenient way to format std::chrono::duration
to a specified format?
std::chrono::high_resolution_clock::time_point now, then;
then
One can use something like:
#include
#include
//...
auto c(timeInMicroSec.count());
std::ostringstream oss;
oss << std::setfill('0') // set field fill character to '0'
<< (c % 1000000000) / 1000000 // format seconds
<< "::"
<< std::setw(3) // set width of milliseconds field
<< (c % 1000000) / 1000 // format milliseconds
<< "::"
<< std::setw(3) // set width of microseconds field
<< c % 1000; // format microseconds
auto formatted(oss.str());