From c5e4d2632045a42d620d929a976a0263fbdc047c Mon Sep 17 00:00:00 2001 From: Sergey Mishin Date: Tue, 5 Oct 2021 10:20:06 +0000 Subject: [PATCH] Fix working without timezone --- src/modules/clock.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 33028b78..7e7d7420 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -29,13 +29,8 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) zone_name.asString() ) ); - } - // If all timezones are parsed and no one is good, add nullptr to the timezones vector, to mark that local time should be shown. - if (!time_zones_.size()) { - time_zones_.push_back(nullptr); - } - } else { + } else if (config_["timezone"].isString() && !config_["timezone"].asString().empty()) { time_zones_.push_back( date::locate_zone( config_["timezone"].asString() @@ -43,6 +38,11 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) ); } + // If all timezones are parsed and no one is good, add nullptr to the timezones vector, to mark that local time should be shown. + if (!time_zones_.size()) { + time_zones_.push_back(nullptr); + } + if (!is_timezone_fixed()) { spdlog::warn("As using a timezone, some format args may be missing as the date library haven't got a release since 2018."); } @@ -105,7 +105,7 @@ auto waybar::modules::Clock::update() -> void { calendar_lines = calendar_text(wtime); } auto tooltip_format = config_["tooltip-format"].asString(); - text = fmt::format(tooltip_format, wtime, fmt::arg("calendar", calendar_lines)); + text = fmt::format(tooltip_format, wtime, fmt::arg(kCalendarPlaceholder.c_str(), calendar_lines)); } }