I have a few lines of code that takes the system clock on my Windows machine and converts it to a double.
std::chrono::time_point<std::chrono::system_clock> currentNow =
std::chrono::system_clock::now();
auto duration = currentNow.time_since_epoch();
double millis = static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
double origin_time = millis / 1000;
I would like to reverse this later on and convert the double to a string being the format YYYY-mm-dd HH:MM:SS.ffffffff
The first step I have right now is taking the double and passing it as a parameter to chrono::duration.
auto rep = std::chrono::duration<double>(origin_time);
How would I go about using the chrono library to achieve the string specified above, thanks!
Aucun commentaire:
Enregistrer un commentaire