Skip to content

Commit

Permalink
widgets: refactor getTime if else brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
davc0n committed Dec 30, 2024
1 parent 6ababf2 commit acbebd3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/renderer/widgets/IWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,14 @@ static std::chrono::hh_mm_ss<std::chrono::system_clock::duration> getTime() {
const std::chrono::time_zone* pCurrentTz = nullptr;
try {
auto name = std::getenv("TZ");
if (name) {
if (name)
pCurrentTz = std::chrono::locate_zone(name);
}
} catch (std::runtime_error&) {
Debug::log(WARN, "Invalid TZ value. Falling back to current timezone!");
}

if (!pCurrentTz) {
if (!pCurrentTz)
pCurrentTz = std::chrono::current_zone();
}

const auto TPNOW = std::chrono::system_clock::now();

Expand All @@ -144,9 +142,8 @@ static std::chrono::hh_mm_ss<std::chrono::system_clock::duration> getTime() {
logMissingTzOnce = false;
}
hhmmss = std::chrono::hh_mm_ss{TPNOW - std::chrono::floor<std::chrono::days>(TPNOW)};
} else {
} else
hhmmss = std::chrono::hh_mm_ss{pCurrentTz->to_local(TPNOW) - std::chrono::floor<std::chrono::days>(pCurrentTz->to_local(TPNOW))};
}

return hhmmss;
}
Expand Down

0 comments on commit acbebd3

Please sign in to comment.