mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
label: Use local time for $TIME variable (#17)
Before this change, system's time zone was not used to return the time
This commit is contained in:
parent
d37786be5c
commit
1049ac9a0b
1 changed files with 5 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue