mirror of
https://github.com/PerMalmberg/libcron.git
synced 2024-11-21 01:10:59 +08:00
#1 Some small code cleanups.
This commit is contained in:
parent
c20a146980
commit
6ed4bc3b2e
@ -142,13 +142,13 @@ namespace libcron
|
||||
for (const auto& name : names)
|
||||
{
|
||||
std::regex m(name, std::regex_constants::ECMAScript | std::regex_constants::icase);
|
||||
for (size_t i = 0; i < parts.size(); ++i)
|
||||
for (auto& part : parts)
|
||||
{
|
||||
std::string replaced;
|
||||
std::regex_replace(std::back_inserter(replaced), parts[i].begin(), parts[i].end(), m,
|
||||
std::regex_replace(std::back_inserter(replaced), part.begin(), part.end(), m,
|
||||
std::to_string(value_of_first_name));
|
||||
|
||||
parts[i] = replaced;
|
||||
part = replaced;
|
||||
}
|
||||
|
||||
value_of_first_name++;
|
||||
@ -235,8 +235,8 @@ namespace libcron
|
||||
|
||||
if (std::regex_match(s.begin(), s.end(), match, range))
|
||||
{
|
||||
auto left = std::stoi(match[1].str().c_str());
|
||||
auto right = std::stoi(match[2].str().c_str());
|
||||
auto left = std::stoi(match[1].str());
|
||||
auto right = std::stoi(match[2].str());
|
||||
|
||||
if (is_within_limits<T>(left, right))
|
||||
{
|
||||
@ -269,10 +269,10 @@ namespace libcron
|
||||
}
|
||||
else
|
||||
{
|
||||
raw_start = std::stoi(match[1].str().c_str());
|
||||
raw_start = std::stoi(match[1].str());
|
||||
}
|
||||
|
||||
auto raw_step = std::stoi(match[2].str().c_str());
|
||||
auto raw_step = std::stoi(match[2].str());
|
||||
|
||||
if (is_within_limits<T>(raw_start, raw_start) && raw_step > 0)
|
||||
{
|
||||
|
@ -90,15 +90,7 @@ namespace libcron
|
||||
// Make sure that if the days contains only 31, at least one month allows that date.
|
||||
if (day_of_month.size() == 1 && day_of_month.find(DayOfMonth::Last) != day_of_month.end())
|
||||
{
|
||||
std::vector<int32_t> months_with_31;
|
||||
for (int32_t i = 1; i <= 12; ++i)
|
||||
{
|
||||
auto ymd = 2018_y / i / date::last;
|
||||
if (unsigned(ymd.day()) == 31)
|
||||
{
|
||||
months_with_31.push_back(i);
|
||||
}
|
||||
}
|
||||
constexpr std::array<uint32_t, 7> months_with_31{1, 3, 5, 7, 8, 10, 12};
|
||||
|
||||
res = false;
|
||||
for (size_t i = 0; !res && i < months_with_31.size(); ++i)
|
||||
|
Loading…
Reference in New Issue
Block a user