refactor(clock): avoid usless duration_cast

pull/364/head
Alex 2019-05-22 11:48:02 +02:00
parent bf5c00ff2a
commit 23d4a811db
1 changed files with 3 additions and 4 deletions

View File

@ -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));
}; };
} }