clock: fix use after scope

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
This commit is contained in:
Lukas Fleischer
2025-08-23 00:24:31 -04:00
parent 41de8964f1
commit 8e488b4d5e

View File

@ -63,8 +63,8 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
if (cldInTooltip_) { if (cldInTooltip_) {
if (config_[kCldPlaceholder]["mode"].isString()) { if (config_[kCldPlaceholder]["mode"].isString()) {
const std::string cfgMode{config_[kCldPlaceholder]["mode"].asString()}; const std::string cfgMode{config_[kCldPlaceholder]["mode"].asString()};
const std::map<std::string_view, const CldMode&> monthModes{{"month", CldMode::MONTH}, const std::map<std::string, CldMode> monthModes{{"month", CldMode::MONTH},
{"year", CldMode::YEAR}}; {"year", CldMode::YEAR}};
if (monthModes.find(cfgMode) != monthModes.end()) if (monthModes.find(cfgMode) != monthModes.end())
cldMode_ = monthModes.at(cfgMode); cldMode_ = monthModes.at(cfgMode);
else else
@ -92,10 +92,8 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
fmtMap_.insert({2, "{}"}); fmtMap_.insert({2, "{}"});
if (config_[kCldPlaceholder]["format"]["today"].isString()) { if (config_[kCldPlaceholder]["format"]["today"].isString()) {
fmtMap_.insert({3, config_[kCldPlaceholder]["format"]["today"].asString()}); fmtMap_.insert({3, config_[kCldPlaceholder]["format"]["today"].asString()});
cldBaseDay_ = auto local_time = zoned_time{local_zone(), system_clock::now()}.get_local_time();
year_month_day{ cldBaseDay_ = year_month_day{floor<days>(local_time)}.day();
floor<days>(zoned_time{local_zone(), system_clock::now()}.get_local_time())}
.day();
} else } else
fmtMap_.insert({3, "{}"}); fmtMap_.insert({3, "{}"});
if (config_[kCldPlaceholder]["format"]["weeks"].isString() && cldWPos_ != WS::HIDDEN) { if (config_[kCldPlaceholder]["format"]["weeks"].isString() && cldWPos_ != WS::HIDDEN) {