mariusbancila / croncpp

A C++11/14/17 header-only cross-platform library for handling CRON expressions
MIT License
236 stars 68 forks source link

"invalid bitset position" thrown when calling cron::cron_next<cron::cron_quartz_traits>(...) #35

Open hanexthink opened 1 year ago

hanexthink commented 1 year ago

Hi, It is noticed that for a date and time entry that correspond to Sundays the cron::cron_next<cron::cron_quartz_traits>(...) function throws an invalid bitset position exception. This case is deterministic and could be produced with following code snippet for example.

        std::tm currentRunTime{};
    currentRunTime.tm_sec = 0;
    currentRunTime.tm_min = 0;
    currentRunTime.tm_hour = 0;
    currentRunTime.tm_mday = 3;
    currentRunTime.tm_mon = 8;
    currentRunTime.tm_year = 123;
    currentRunTime.tm_wday = 0;
    currentRunTime.tm_yday = 245;
    currentRunTime.tm_isdst = 1;

    auto quartzExpression{ "0 0 */12 * * 1-7" };
    auto cronExpr = cron::make_cron<cron::cron_quartz_traits>(quartzExpression);
    auto nextRunTime = cron::cron_next<cron::cron_quartz_traits>(cronExpr, currentRunTime);

We'll be glad to have your insight on this subject. Kind regards, Hossein Afshari

image