statustime: Only update when the minute changes.
This commit is contained in:
parent
194212dbaa
commit
2c1484587f
|
@ -13,6 +13,8 @@ int main()
|
||||||
{
|
{
|
||||||
using fmt::format;
|
using fmt::format;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
using clock = std::chrono::system_clock;
|
||||||
|
using std::chrono::minutes;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
// Set explicitly, because LC_TIME is en_DK.UTF-8.
|
// Set explicitly, because LC_TIME is en_DK.UTF-8.
|
||||||
|
@ -22,12 +24,15 @@ int main()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
const auto now{clock::now()};
|
||||||
cout << format(R"(<b><span color="orange">{0:%A}</span></b>, )"
|
cout << format(R"(<b><span color="orange">{0:%A}</span></b>, )"
|
||||||
R"({0:%Y-%m-%d} )"
|
R"({0:%Y-%m-%d} )"
|
||||||
R"(<span color="lightcyan">{0:%H:%M}</span>)",
|
R"(<span color="lightcyan">{0:%H:%M}</span>)",
|
||||||
std::chrono::system_clock::now())
|
now)
|
||||||
<< std::endl; // NOTE: Don't forget that we need to flush! 😊
|
<< std::endl; // NOTE: Don't forget that we need to flush! 😊
|
||||||
std::this_thread::sleep_for(1s);
|
|
||||||
|
const auto next_minute{std::chrono::floor<minutes>(now + 1min)};
|
||||||
|
std::this_thread::sleep_until(next_minute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user