From 392948cdee6f783dbae48dbadb0ca5286eaaeeda Mon Sep 17 00:00:00 2001 From: Per Malmberg Date: Sun, 25 Mar 2018 10:22:33 +0200 Subject: [PATCH] Compile on Linux again. --- libcron/Cron.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/libcron/Cron.h b/libcron/Cron.h index e2a07b3..4b0802d 100644 --- a/libcron/Cron.h +++ b/libcron/Cron.h @@ -45,7 +45,8 @@ namespace libcron return clock; } - void get_time_until_expiry_for_tasks(std::vector>& status) const; + void get_time_until_expiry_for_tasks( + std::vector>& status) const; friend std::ostream& operator<<<>(std::ostream& stream, const Cron& c); @@ -93,10 +94,10 @@ namespace libcron template std::chrono::system_clock::duration Cron::time_until_next() const { - system_clock::duration d{}; + std::chrono::system_clock::duration d{}; if (tasks.empty()) { - d = std::numeric_limits::max(); + d = std::numeric_limits::max(); } else { @@ -115,7 +116,7 @@ namespace libcron { first_tick = false; } - else if (now > last_tick && now - last_tick <= hours{3}) + else if (now > last_tick && now - last_tick <= std::chrono::hours{3}) { // Reschedule all tasks. for (auto& t : tasks.get_tasks()) @@ -123,7 +124,7 @@ namespace libcron t.calculate_next(now); } } - else if (now < last_tick && now - last_tick <= -hours{3}) + else if (now < last_tick && now - last_tick <= -std::chrono::hours{3}) { // Reschedule all tasks. for (auto& t : tasks.get_tasks()) @@ -152,6 +153,7 @@ namespace libcron { // Must calculate new schedules using second after 'now', otherwise // we'll run the same task over and over if it takes less than 1s to execute. + using namespace std::chrono_literals; if (task.calculate_next(now + 1s)) { tasks.push(task); @@ -161,18 +163,19 @@ namespace libcron return res; } - template - void Cron::get_time_until_expiry_for_tasks(std::vector>& status) const - { - auto now = clock.now(); - status.clear(); + template + void Cron::get_time_until_expiry_for_tasks(std::vector>& status) const + { + auto now = clock.now(); + status.clear(); - std::for_each(tasks.get_tasks().cbegin(), tasks.get_tasks().cend(), - [&status, &now](const Task& t) - { - status.emplace_back(t.get_name(), t.time_until_expiry(now)); - }); - } + std::for_each(tasks.get_tasks().cbegin(), tasks.get_tasks().cend(), + [&status, &now](const Task& t) + { + status.emplace_back(t.get_name(), t.time_until_expiry(now)); + }); + } template std::ostream& operator<<(std::ostream& stream, const Cron& c)