dimanche 27 septembre 2015

Add time duration to C++ timepoint

I have a starting timepoint in milliseconds like so:

using namespace std::chrono;
typedef time_point<system_clock, milliseconds> MyTimePoint;

MyTimePoint startTimePoint = time_point_cast<MyTimePoint::duration>(system_clock::time_point(steady_clock::now()));

Now I will have a certain number of hours that I want to add or subtract to the startTimePoint.

int numHours = -5//or 5 etc (Can be a plus or minus number)

How can I add this abount of time to the original startTimePoint??

Aucun commentaire:

Enregistrer un commentaire