From: Thomas Jarosch Date: Wed, 28 Jan 2009 17:31:38 +0000 (+0100) Subject: Merge commit 'origin/arnied-clockchange' into arnied-clockchange X-Git-Tag: v2.6~136^2~14 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=296235cfa713ab49f03a2fd0d013b7f7c0ca4774;p=libi2ncommon Merge commit 'origin/arnied-clockchange' into arnied-clockchange Conflicts: libi2ncommon/src/cron.cpp libi2ncommon/src/cron.hpp --- 296235cfa713ab49f03a2fd0d013b7f7c0ca4774 diff --cc src/cron.cpp index 4fe9ca1,b0f954c..5fd23ea --- a/src/cron.cpp +++ b/src/cron.cpp @@@ -8,14 -8,12 +8,15 @@@ * */ #include - #include - #include + #include + namespace I2n { + namespace Time { + +const time_t WeekCron::StNimmerleinsDay = static_cast(-1); + /** * Constructor * @param daystring String representing the active weekdays as numbers. 0 is Sunday. @@@ -82,10 -78,10 +83,10 @@@ time_t WeekCron::get_next_run(time_t ca throw std::runtime_error("illegal cron value"); if (calc_from <= 86400*14) - throw std::runtime_error("WeekCron doesn't work for times near 0"); + throw std::runtime_error("WeekCron doesn't work for timestamps near 0"); if (Week.none_set()) - return 0; + return StNimmerleinsDay; if (Every == -1) { @@@ -156,17 -152,16 +158,17 @@@ time_t WeekCron::get_next_point(const t } /** - * Returns the last point in time the item is scheduled for + * Returns the previous or current point in time the item was scheduled for. + * Does not care about intervals. + * 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_previousnow_point(time_t calc_from, int daysec, bool todaycheck) -time_t WeekCron::get_lastnow_point(const time_t calc_from, const int daysec, const bool todaycheck) ++time_t WeekCron::get_previousnow_point(const time_t calc_from, const int daysec, const bool todaycheck) { struct tm ft; localtime_r(&calc_from,&ft); diff --cc src/cron.hpp index d976e78,b634e3f..ff0bd3e --- a/src/cron.hpp +++ b/src/cron.hpp @@@ -11,11 -11,13 +11,13 @@@ #define __CRON_HPP #include + #include - #include + namespace I2n { + namespace Time { -/// Time points and intervals repeating each week /** + @brief Time points and intervals repeating each week This class represents recurring time points and intervals which can be repeated on configurable days of the week. */ @@@ -32,14 -31,14 +34,14 @@@ class WeekCro /// Repeat event every xxx seconds in the half-open interval of #Begin and #End. -1 is disabled int Every; /// Stores the active days this WeekCron is valid for - WEEK Week; + I2n::Time::Week Week; - time_t get_next_point(time_t calc_from, int daysec,bool todaycheck); - time_t get_previousnow_point(time_t calc_from, int daysec,bool todaycheck); + time_t get_next_point(const time_t calc_from, const int daysec, const bool todaycheck); - time_t get_lastnow_point(const time_t calc_from, const int daysec, const bool todaycheck); ++ time_t get_previousnow_point(const time_t calc_from, const int daysec, const bool todaycheck); public: - WeekCron(const std::string& daystring, int begin); - WeekCron(const std::string& daystring, int begin, int end, int every); + WeekCron(const std::string& daystring, const int begin); + WeekCron(const std::string& daystring, const int begin, const int end, const int every); bool is_sane() const;