diff --git a/statustime.cpp b/statustime.cpp
index d62fd8b..c2e7e89 100755
--- a/statustime.cpp
+++ b/statustime.cpp
@@ -13,6 +13,8 @@ int main()
{
using fmt::format;
using std::cout;
+ using clock = std::chrono::system_clock;
+ using std::chrono::minutes;
using namespace std::chrono_literals;
// Set explicitly, because LC_TIME is en_DK.UTF-8.
@@ -22,12 +24,15 @@ int main()
{
while (true)
{
+ const auto now{clock::now()};
cout << format(R"({0:%A}, )"
R"({0:%Y-%m-%d} )"
R"({0:%H:%M})",
- std::chrono::system_clock::now())
+ now)
<< std::endl; // NOTE: Don't forget that we need to flush! 😊
- std::this_thread::sleep_for(1s);
+
+ const auto next_minute{std::chrono::floor(now + 1min)};
+ std::this_thread::sleep_until(next_minute);
}
}
catch (const std::exception &e)