if (!is_sane())
throw std::runtime_error("illegal cron value");
- if (calc_from <= 86400)
+ if (calc_from <= 86400*14)
throw std::runtime_error("WeekCron doesn't work for times near 0");
if (week.none_set())
time_t since_lastrun=within_interval % every;
time_t next_exec=calc_from+(every-since_lastrun);
- // next step after end?
- if (next_exec > get_next_point(calc_from,end,true))
+ // next step at or after end?
+ if (next_exec >= get_next_point(calc_from,end,true))
return get_next_point(calc_from,begin,true);
else
return next_exec;
CPPUNIT_TEST(IntervalBeginStep);
CPPUNIT_TEST(IntervalWithin);
CPPUNIT_TEST(IntervalLaststep);
+ CPPUNIT_TEST(IntervalLaststepMatch);
CPPUNIT_TEST(IntervalEnd);
CPPUNIT_TEST(IntervalBigstep);
CPPUNIT_ASSERT_EQUAL( 1233187200, static_cast<int>(cron.get_next_run(1233104399)));
}
+ void IntervalLaststepMatch()
+ {
+ WeekCron cron("2345",3600,7200,10);
+ CPPUNIT_ASSERT_EQUAL( 1233187200, static_cast<int>(cron.get_next_run(1233104399)));
+ }
+
void IntervalEnd()
{
WeekCron cron("2345",3600,7200,10);