mercredi 9 décembre 2020

chrono measure left time

I want to measure the time left until the next action. I have an online game, where I want to measure spawn times.. Time left until next spawn.

auto now = std::chrono::system_clock::now();
auto now_c = std::chrono::system_clock::to_time_t(now - std::chrono::hours(12) - std::chrono::minutes(22));

char buf[100] = {0};
std::strftime(buf, sizeof(buf), "%H:%M:%S", std::localtime(&now_c));
return buf;

Above you have my actual code.

For example, the next spawn time for a boss is in 12 hours and 22 minutes., I want to measure how much time left until the next spawn (since now). I want the exact time hour minutes seconds. What I do wrong?

Aucun commentaire:

Enregistrer un commentaire