Merge pull request #2838 from m-bdf/clock-tz-changes

This commit is contained in:
Alexis Rouillard 2024-01-16 22:48:31 +01:00 committed by GitHub
commit 392f83e71d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -28,7 +28,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
if (!zone_name.isString()) continue; if (!zone_name.isString()) continue;
if (zone_name.asString().empty()) if (zone_name.asString().empty())
// local time should be shown // local time should be shown
tzList_.push_back(current_zone()); tzList_.push_back(nullptr);
else else
try { try {
tzList_.push_back(locate_zone(zone_name.asString())); tzList_.push_back(locate_zone(zone_name.asString()));
@ -39,7 +39,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
} else if (config_["timezone"].isString()) { } else if (config_["timezone"].isString()) {
if (config_["timezone"].asString().empty()) if (config_["timezone"].asString().empty())
// local time should be shown // local time should be shown
tzList_.push_back(current_zone()); tzList_.push_back(nullptr);
else else
try { try {
tzList_.push_back(locate_zone(config_["timezone"].asString())); tzList_.push_back(locate_zone(config_["timezone"].asString()));
@ -47,7 +47,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
spdlog::warn("Timezone: {0}. {1}", config_["timezone"].asString(), e.what()); spdlog::warn("Timezone: {0}. {1}", config_["timezone"].asString(), e.what());
} }
} }
if (!tzList_.size()) tzList_.push_back(current_zone()); if (!tzList_.size()) tzList_.push_back(nullptr);
// Calendar properties // Calendar properties
if (cldInTooltip_) { if (cldInTooltip_) {
@ -84,7 +84,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
fmtMap_.insert({3, config_[kCldPlaceholder]["format"]["today"].asString()}); fmtMap_.insert({3, config_[kCldPlaceholder]["format"]["today"].asString()});
cldBaseDay_ = cldBaseDay_ =
year_month_day{ year_month_day{
floor<days>(zoned_time{current_zone(), system_clock::now()}.get_local_time())} floor<days>(zoned_time{nullptr, system_clock::now()}.get_local_time())}
.day(); .day();
} else } else
fmtMap_.insert({3, "{}"}); fmtMap_.insert({3, "{}"});
@ -127,7 +127,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
} }
auto waybar::modules::Clock::update() -> void { auto waybar::modules::Clock::update() -> void {
auto tz{tzList_[tzCurrIdx_]}; auto tz{tzList_[tzCurrIdx_] ?: current_zone()};
const zoned_time now{tz, floor<seconds>(system_clock::now())}; const zoned_time now{tz, floor<seconds>(system_clock::now())};
label_.set_markup(fmt_lib::vformat(locale_, format_, fmt_lib::make_format_args(now))); label_.set_markup(fmt_lib::vformat(locale_, format_, fmt_lib::make_format_args(now)));