mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor(clock): use fmt::localtime
This commit is contained in:
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
Block a user