refactor WeekCron: rename get_lastnow_point to _previousnow_
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 28 Jan 2009 10:12:25 +0000 (11:12 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 28 Jan 2009 10:12:25 +0000 (11:12 +0100)
src/cron.cpp
src/cron.hpp

index 77d9eb4..463bbdb 100644 (file)
@@ -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;
index 91fdc23..f3d98a8 100644 (file)
@@ -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);