From d70ccb7a1f907bece085ab16a924c81b6ef25886 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 28 Jan 2009 11:12:25 +0100 Subject: [PATCH] refactor WeekCron: rename get_lastnow_point to _previousnow_ --- src/cron.cpp | 19 ++++++++++--------- src/cron.hpp | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cron.cpp b/src/cron.cpp index 77d9eb4..463bbdb 100644 --- a/src/cron.cpp +++ b/src/cron.cpp @@ -94,7 +94,7 @@ time_t WeekCron::get_next_run(time_t calc_from) { // next begin > next end means we are at the begin or within the interval - time_t interval_begin=get_lastnow_point(calc_from,Begin,true); + time_t interval_begin=get_previousnow_point(calc_from,Begin,true); time_t within_interval=calc_from - interval_begin; time_t since_lastrun=within_interval % Every; @@ -115,7 +115,8 @@ time_t WeekCron::get_next_run(time_t calc_from) } /** - * Returns the next point in time the item is scheduled for + * Returns the next point in time the item is scheduled for. + * Returns next point if scheduled for #calc_from. * @param calc_from Point of time to start calculations from * @param daysec Start point of time in seconds since the start of the day * @param todaycheck If true we check if the calculated time point is before @@ -150,16 +151,16 @@ time_t WeekCron::get_next_point(time_t calc_from, int daysec, bool todaycheck) } /** - * Returns the last point in time the item is scheduled for + * Returns the previous or current point in time the item was scheduled for. + * Returns #calc_from if scheduled for #calc_from. * @param calc_from Point of time to start calculations from * @param daysec Start point of time in seconds since the start of the day - * @param todaycheck If true we check if the calculated time point is before + * @param todaycheck If true we check if the calculated time point is after our #calc_from calcucation start point. - If yes, we will advance to the next day. - * @return Last point in time - * FIXME: Is the description correct? + If yes, we will go back to the previos day + * @return Previous point in time */ -time_t WeekCron::get_lastnow_point(time_t calc_from, int daysec, bool todaycheck) +time_t WeekCron::get_previousnow_point(time_t calc_from, int daysec, bool todaycheck) { struct tm ft; localtime_r(&calc_from,&ft); @@ -180,7 +181,7 @@ time_t WeekCron::get_lastnow_point(time_t calc_from, int daysec, bool todaycheck // not today but the next matching weekday localtime_r(&calc_from,&ft); ft.tm_mday--; - return get_next_point(mktime(&ft),daysec,false); + return get_previousnow_point(mktime(&ft),daysec,false); } return target; diff --git a/src/cron.hpp b/src/cron.hpp index 91fdc23..f3d98a8 100644 --- a/src/cron.hpp +++ b/src/cron.hpp @@ -32,7 +32,7 @@ class WeekCron WEEK Week; time_t get_next_point(time_t calc_from, int daysec,bool todaycheck); - time_t get_lastnow_point(time_t calc_from, int daysec,bool todaycheck); + time_t get_previousnow_point(time_t calc_from, int daysec,bool todaycheck); public: WeekCron(const std::string& daystring, int begin); -- 1.7.1