79802383

Date: 2025-10-28 02:47:44
Score: 2
Natty:
Report link

Another option is to round up the current time to the nearest second using ceil():

auto next_second = std::chrono::ceil<std::chrono::seconds>(
std::chrono::system_clock::now());

If you want to wait until this second has been reached before running some further code, you can add in:

std::this_thread::sleep_until(next_second);

(This code was based on https://en.cppreference.com/w/cpp/chrono/time_point/round, Bames53's response at https://stackoverflow.com/a/9747668/13097194, and https://en.cppreference.com/w/cpp/thread/sleep_until.html .)

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: KBurchfiel