I am taking a system_clock time_point, converting it to a string, and then saving it to a configuration file.
Now I want to read that config file and turn the string back into a time point so that I can calculate the difference in time between two time points.
void SaveLastShuffleTime() {
m_lastShuffleTime = std::chrono::system_clock::now();
auto m_lastShuffleTimeTimeT = std::chrono::system_clock::to_time_t(m_lastShuffleTimeTimepoint);
stringstream m_lastShuffeTimeSS;
m_lastShuffeTimeSS << std::put_time(std::localtime(&m_lastShuffleTimeTimeT), "%Y-%m-%d %X");
m_deviceStateSettings.UpdateDeviceStateSettings(LAST_SHUFFLE_TIME, m_lastShuffeTimeSS.str());
}
void CompareLastShuffleTime() {
m _currentShuffleTime = std::chrono::system_clock::now();
/* READ CONFIG FILE AND CONVERT BACK TO TIME POINT */
int timeSinceLastShuffle = (duration_cast<minutes>(m_currentShuffleTime - m_oldShuffleTime)).count();
}
Please let me know if this is viable. The alternative is to save the timepoint as an integer but I would prefer not to do that.
Thanks