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