Fix working without timezone

This commit is contained in:
Sergey Mishin 2021-10-05 10:20:06 +00:00
parent d8bc6c92bb
commit c5e4d26320
No known key found for this signature in database
GPG Key ID: BFFA09D74430117B
1 changed files with 7 additions and 7 deletions

View File

@ -29,13 +29,8 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
zone_name.asString() 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. } else if (config_["timezone"].isString() && !config_["timezone"].asString().empty()) {
if (!time_zones_.size()) {
time_zones_.push_back(nullptr);
}
} else {
time_zones_.push_back( time_zones_.push_back(
date::locate_zone( date::locate_zone(
config_["timezone"].asString() 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()) { 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."); 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); calendar_lines = calendar_text(wtime);
} }
auto tooltip_format = config_["tooltip-format"].asString(); 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));
} }
} }