Skip to content

Commit

Permalink
Merge pull request #2838 from m-bdf/clock-tz-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexays authored Jan 16, 2024
2 parents 07eabc5 + d343f61 commit 392f83e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/modules/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
if (!zone_name.isString()) continue;
if (zone_name.asString().empty())
// local time should be shown
tzList_.push_back(current_zone());
tzList_.push_back(nullptr);
else
try {
tzList_.push_back(locate_zone(zone_name.asString()));
Expand All @@ -39,15 +39,15 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
} else if (config_["timezone"].isString()) {
if (config_["timezone"].asString().empty())
// local time should be shown
tzList_.push_back(current_zone());
tzList_.push_back(nullptr);
else
try {
tzList_.push_back(locate_zone(config_["timezone"].asString()));
} catch (const std::exception& e) {
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);

Check warning on line 50 in src/modules/clock.cpp

View workflow job for this annotation

GitHub Actions / build

src/modules/clock.cpp:50:8 [readability-container-size-empty]

the 'empty' method should be used to check for emptiness instead of 'size'

Check warning on line 50 in src/modules/clock.cpp

View workflow job for this annotation

GitHub Actions / build

src/modules/clock.cpp:50:8 [readability-implicit-bool-conversion]

implicit conversion 'size_type' (aka 'unsigned long') -> bool

// Calendar properties
if (cldInTooltip_) {
Expand Down Expand Up @@ -84,7 +84,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
fmtMap_.insert({3, config_[kCldPlaceholder]["format"]["today"].asString()});
cldBaseDay_ =
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();
} else
fmtMap_.insert({3, "{}"});
Expand Down Expand Up @@ -127,7 +127,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
}

auto waybar::modules::Clock::update() -> void {
auto tz{tzList_[tzCurrIdx_]};
auto tz{tzList_[tzCurrIdx_] ?: current_zone()};

Check warning on line 130 in src/modules/clock.cpp

View workflow job for this annotation

GitHub Actions / build

src/modules/clock.cpp:130:3 [readability-qualified-auto]

'auto tz' can be declared as 'const auto *tz'

Check warning on line 130 in src/modules/clock.cpp

View workflow job for this annotation

GitHub Actions / build

src/modules/clock.cpp:130:11 [readability-implicit-bool-conversion]

implicit conversion 'value_type' (aka 'const std::chrono::time_zone *') -> bool
const zoned_time now{tz, floor<seconds>(system_clock::now())};

label_.set_markup(fmt_lib::vformat(locale_, format_, fmt_lib::make_format_args(now)));
Expand Down

0 comments on commit 392f83e

Please sign in to comment.