fix(clock): crash on scrolling with local timezone (`""`) in the list
While we at it, eliminate use of non-portable GCC conditional expression syntax. There are no significant side-effects that would justify use of the language extension.
This commit is contained in:
parent
ce5a1cf2f9
commit
a2deff3689
|
@ -130,7 +130,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_] ?: current_zone()};
|
const auto* tz = tzList_[tzCurrIdx_] != nullptr ? 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)));
|
||||||
|
@ -167,7 +167,8 @@ auto waybar::modules::Clock::getTZtext(sys_seconds now) -> std::string {
|
||||||
std::stringstream os;
|
std::stringstream os;
|
||||||
for (size_t tz_idx{0}; tz_idx < tzList_.size(); ++tz_idx) {
|
for (size_t tz_idx{0}; tz_idx < tzList_.size(); ++tz_idx) {
|
||||||
if (static_cast<int>(tz_idx) == tzCurrIdx_) continue;
|
if (static_cast<int>(tz_idx) == tzCurrIdx_) continue;
|
||||||
auto zt{zoned_time{tzList_[tz_idx], now}};
|
const auto* tz = tzList_[tz_idx] != nullptr ? tzList_[tz_idx] : current_zone();
|
||||||
|
auto zt{zoned_time{tz, now}};
|
||||||
os << fmt_lib::vformat(locale_, format_, fmt_lib::make_format_args(zt)) << '\n';
|
os << fmt_lib::vformat(locale_, format_, fmt_lib::make_format_args(zt)) << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue