refactor(clock): use fmt::localtime

pull/25/head
Alexis 2018-08-15 20:53:27 +02:00
parent d427512d7d
commit 608b791ac1
2 changed files with 4 additions and 4 deletions

View File

@ -2,6 +2,7 @@
#include <json/json.h>
#include <fmt/format.h>
#include "fmt/time.h"
#include "util/chrono.hpp"
#include "IModule.hpp"

View File

@ -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 &() {