diff --git a/libcron/include/libcron/CronData.h b/libcron/include/libcron/CronData.h index ae42392..5437b87 100644 --- a/libcron/include/libcron/CronData.h +++ b/libcron/include/libcron/CronData.h @@ -11,7 +11,8 @@ namespace libcron class CronData { public: - static const std::array months_with_31; + static const int NUMBER_OF_LONG_MONTHS = 7; + static const libcron::Months months_with_31[NUMBER_OF_LONG_MONTHS]; static CronData create(const std::string& cron_expression); diff --git a/libcron/src/CronData.cpp b/libcron/src/CronData.cpp index 1407fe3..6ee9dbc 100644 --- a/libcron/src/CronData.cpp +++ b/libcron/src/CronData.cpp @@ -5,13 +5,13 @@ using namespace date; namespace libcron { - const constexpr std::array CronData::months_with_31{ Months::January, - Months::March, - Months::May, - Months::July, - Months::August, - Months::October, - Months::December }; + const constexpr Months CronData::months_with_31[NUMBER_OF_LONG_MONTHS] = { Months::January, + Months::March, + Months::May, + Months::July, + Months::August, + Months::October, + Months::December }; CronData CronData::create(const std::string& cron_expression) { @@ -98,7 +98,7 @@ namespace libcron { res = false; - for (size_t i = 0; !res && i < months_with_31.size(); ++i) + for (size_t i = 0; !res && i < NUMBER_OF_LONG_MONTHS; ++i) { res = months.find(months_with_31[i]) != months.end(); } diff --git a/libcron/src/CronRandomization.cpp b/libcron/src/CronRandomization.cpp index b8efac3..144fbcb 100644 --- a/libcron/src/CronRandomization.cpp +++ b/libcron/src/CronRandomization.cpp @@ -87,9 +87,9 @@ namespace libcron // Limit to 29 days, possibly causing delaying schedule until next leap year. max = std::min(max, 29); } - else if (std::find(CronData::months_with_31.begin(), - CronData::months_with_31.end(), - month) == CronData::months_with_31.end()) + else if (std::find(std::begin(CronData::months_with_31), + std::end(CronData::months_with_31), + month) == std::end(CronData::months_with_31)) { // Not among the months with 31 days max = std::min(max, 30);