mardi 21 juillet 2015

Validate timestamp for a particular duration in C++

I want to see whether my data is 120 second old by looking at the timestamp of the data so I have below code:

uint64_t now = duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count();
bool is_old = (120 * 1000 < (now - data_holder->getTimestamp()));

In the above code data_holder->getTimestamp() is uint64_t. Does my above code looks right?

Aucun commentaire:

Enregistrer un commentaire