Merge commit 'origin/arnied-clockchange' into arnied-clockchange
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 28 Jan 2009 17:31:38 +0000 (18:31 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 28 Jan 2009 17:31:38 +0000 (18:31 +0100)
Conflicts:
libi2ncommon/src/cron.cpp
libi2ncommon/src/cron.hpp

1  2 
src/cron.cpp
src/cron.hpp
test/test_cron.cpp

diff --cc src/cron.cpp
@@@ -8,14 -8,12 +8,15 @@@
   *
   */
  #include <time.h>
  #include <stdexcept>
- #include <iostream>
 +
  #include <cron.hpp>
  
+ namespace I2n {
+ namespace Time {
 +const time_t WeekCron::StNimmerleinsDay = static_cast<time_t>(-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
  #define __CRON_HPP
  
  #include <time.h>
+ #include <week.hpp>
  
- #include <timefunc.hxx>
+ 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;
  
Simple merge