| 15 | } |
| 16 | |
| 17 | auto waybar::modules::Clock::update() -> void { |
| 18 | tzset(); // Update timezone information |
| 19 | auto now = std::chrono::system_clock::now(); |
| 20 | auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now)); |
| 21 | auto text = fmt::format(fmt::runtime(format_), localtime); |
| 22 | label_.set_markup(text); |
| 23 | |
| 24 | if (tooltipEnabled()) { |
| 25 | if (config_["tooltip-format"].isString()) { |
| 26 | auto tooltip_format = config_["tooltip-format"].asString(); |
| 27 | auto tooltip_text = fmt::format(fmt::runtime(tooltip_format), localtime); |
| 28 | label_.set_tooltip_text(tooltip_text); |
| 29 | } else { |
| 30 | label_.set_tooltip_text(text); |
| 31 | } |
| 32 | } |
| 33 | // Call parent update |
| 34 | ALabel::update(); |
| 35 | } |