refactor(clock): use fmt::localtime
parent
d427512d7d
commit
608b791ac1
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <json/json.h>
|
||||
#include <fmt/format.h>
|
||||
#include "fmt/time.h"
|
||||
#include "util/chrono.hpp"
|
||||
#include "IModule.hpp"
|
||||
|
||||
|
|
|
@ -15,11 +15,10 @@ waybar::modules::Clock::Clock(Json::Value config)
|
|||
|
||||
auto waybar::modules::Clock::update() -> void
|
||||
{
|
||||
auto t = std::time(nullptr);
|
||||
auto localtime = std::localtime(&t);
|
||||
auto localtime = fmt::localtime(std::time(nullptr));
|
||||
auto format =
|
||||
_config["format"] ? _config["format"].asString() : "{:02}:{:02}";
|
||||
_label.set_text(fmt::format(format, localtime->tm_hour, localtime->tm_min));
|
||||
_config["format"] ? _config["format"].asString() : "{:%H:%M}";
|
||||
_label.set_text(fmt::format(format, localtime));
|
||||
}
|
||||
|
||||
waybar::modules::Clock::operator Gtk::Widget &() {
|
||||
|
|
Loading…
Reference in New Issue