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,15 +37,19 @@ public:
} }
private: private:
void update_clock();
sixtyfps::Timer clock_update_timer; sixtyfps::Timer clock_update_timer;
}; };
ClockWidget::ClockWidget() ClockWidget::ClockWidget() : clock_update_timer(std::chrono::seconds(1), [=]() { update_clock() })
: clock_update_timer(std::chrono::seconds(1), [=]() { {
}
void ClockWidget::update_clock()
{
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr))); std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
set_property("time", sixtyfps::SharedString(current_time)); set_property("time", sixtyfps::SharedString(current_time));
})
{
} }
int main() int main()