From 5774a519b9f6f914f450eb8a80bf29c328c2f4bd Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 28 Jan 2009 10:30:16 +0100 Subject: [PATCH] Renamed variables to match i2n code style --- src/cron.cpp | 36 ++++++++++++++++++------------------ src/cron.hpp | 20 ++++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/cron.cpp b/src/cron.cpp index 6a4118a..f31032d 100644 --- a/src/cron.cpp +++ b/src/cron.cpp @@ -16,16 +16,16 @@ /** @brief checks if the values are usable */ -bool WeekCron::is_sane() +bool WeekCron::is_sane() const { - if (begin < 0 || begin > 86399) + if (Begin < 0 || Begin > 86399) return false; - if (every != -1) + if (Every != -1) { - if (end < 0 || end > 86400 || - every < 1 || every > 86400 || - begin > end) + if (End < 0 || End > 86400 || + Every < 1 || Every > 86400 || + Begin > End) return false; } @@ -48,37 +48,37 @@ time_t WeekCron::get_next_run(time_t calc_from) if (calc_from <= 86400*14) throw std::runtime_error("WeekCron doesn't work for times near 0"); - if (week.none_set()) + if (Week.none_set()) return 0; - if (every == -1) + if (Every == -1) { // point in time - return get_next_point(calc_from,begin,true); + return get_next_point(calc_from,Begin,true); } else { // interval - if (get_next_point(calc_from,begin,true) > get_next_point(calc_from,end-1,true)) + if (get_next_point(calc_from,Begin,true) > get_next_point(calc_from,End-1,true)) { // 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_lastnow_point(calc_from,Begin,true); time_t within_interval=calc_from - interval_begin; - time_t since_lastrun=within_interval % every; - time_t next_exec=calc_from+(every-since_lastrun); + time_t since_lastrun=within_interval % Every; + time_t next_exec=calc_from+(Every-since_lastrun); // next step at or after end? - if (next_exec >= get_next_point(calc_from,end,true)) - return get_next_point(calc_from,begin,true); + if (next_exec >= get_next_point(calc_from,End,true)) + return get_next_point(calc_from,Begin,true); else return next_exec; } else { // next begin < next end means we are out of the interval: next begin is next run - return get_next_point(calc_from,begin,true); + return get_next_point(calc_from,Begin,true); } } } @@ -89,7 +89,7 @@ time_t WeekCron::get_next_point(time_t calc_from, int daysec, bool todaycheck) localtime_r(&calc_from,&ft); // take care of the weekday - ft.tm_mday+=week.days_till_set(static_cast(ft.tm_wday)); + ft.tm_mday+=Week.days_till_set(static_cast(ft.tm_wday)); ft.tm_hour=0; ft.tm_min=0; @@ -115,7 +115,7 @@ time_t WeekCron::get_lastnow_point(time_t calc_from, int daysec, bool todaycheck localtime_r(&calc_from,&ft); // take care of the weekday - ft.tm_mday-=week.days_since_set(static_cast(ft.tm_wday)); + ft.tm_mday-=Week.days_since_set(static_cast(ft.tm_wday)); ft.tm_hour=0; ft.tm_min=0; diff --git a/src/cron.hpp b/src/cron.hpp index 41cd418..dcc0dbd 100644 --- a/src/cron.hpp +++ b/src/cron.hpp @@ -22,10 +22,10 @@ class WeekCron { private: - int begin; - int end; - int every; - WEEK week; + int Begin; + int End; + int Every; + 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); @@ -33,18 +33,18 @@ class WeekCron public: WeekCron(void) - : begin(0), end(0), every(-1), week() + : Begin(0), End(0), Every(-1) { } - WeekCron(const std::string& daystring, int _begin) - : begin(_begin), end(0), every(-1), week(daystring) + WeekCron(const std::string& daystring, int begin) + : Begin(begin), End(0), Every(-1), Week(daystring) { } - WeekCron(const std::string& daystring, int _begin, int _end, int _every) - : begin(_begin), end(_end), every(_every), week(daystring) + WeekCron(const std::string& daystring, int begin, int end, int every) + : Begin(begin), End(end), Every(every), Week(daystring) { } - bool is_sane(); + bool is_sane() const; time_t get_next_run(time_t calc_from=0); -- 1.7.1