Skip to content

Commit

Permalink
label: Use local time for $TIME variable (#17)
Browse files Browse the repository at this point in the history
Before this change, system's time zone was not used to return the time
  • Loading branch information
CIAvash authored Feb 20, 2024
1 parent d37786b commit 1049ac9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/renderer/widgets/IWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ static void replaceAll(std::string& str, const std::string& from, const std::str
}

static std::string getTime() {
const auto HHMMSS = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
const auto HRS = HHMMSS.hours().count();
const auto MINS = HHMMSS.minutes().count();
const auto current_zone = std::chrono::current_zone();
const auto HHMMSS = std::chrono::hh_mm_ss{current_zone->to_local(std::chrono::system_clock::now()) -
std::chrono::floor<std::chrono::days>(current_zone->to_local(std::chrono::system_clock::now()))};
const auto HRS = HHMMSS.hours().count();
const auto MINS = HHMMSS.minutes().count();
return (HRS < 10 ? "0" : "") + std::to_string(HRS) + ":" + (MINS < 10 ? "0" : "") + std::to_string(MINS);
}

Expand Down

0 comments on commit 1049ac9

Please sign in to comment.