refactor(clock): avoid usless duration_cast
This commit is contained in:
parent
bf5c00ff2a
commit
23d4a811db
|
@ -10,11 +10,10 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||||
dp.emit();
|
dp.emit();
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_);
|
auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_);
|
||||||
auto time_s = std::chrono::time_point_cast<std::chrono::seconds>(timeout);
|
auto time_point =
|
||||||
auto sub_m =
|
std::chrono::time_point_cast<std::chrono::seconds>(timeout).time_since_epoch().count() %
|
||||||
std::chrono::duration_cast<std::chrono::seconds>(time_s.time_since_epoch()).count() %
|
|
||||||
interval_.count();
|
interval_.count();
|
||||||
thread_.sleep_until(timeout - std::chrono::seconds(sub_m));
|
thread_.sleep_until(timeout - std::chrono::seconds(time_point));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue