Clean up the clock code a little bit

This commit is contained in:
Simon Hausmann 2021-05-17 17:44:43 +02:00
parent 50d2fa88c7
commit 760a6ef6c5

View file

@ -37,17 +37,21 @@ public:
}
private:
void update_clock();
sixtyfps::Timer clock_update_timer;
};
ClockWidget::ClockWidget()
: clock_update_timer(std::chrono::seconds(1), [=]() {
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
set_property("time", sixtyfps::SharedString(current_time));
})
ClockWidget::ClockWidget() : clock_update_timer(std::chrono::seconds(1), [=]() { update_clock() })
{
}
void ClockWidget::update_clock()
{
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
set_property("time", sixtyfps::SharedString(current_time));
}
int main()
{
DashboardBuilder builder;