summaryrefslogtreecommitdiffstats
path: root/library/cpp/cron_expression/cron_expression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'library/cpp/cron_expression/cron_expression.cpp')
-rw-r--r--library/cpp/cron_expression/cron_expression.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/cpp/cron_expression/cron_expression.cpp b/library/cpp/cron_expression/cron_expression.cpp
index 55b64ee6d24..31a538a0766 100644
--- a/library/cpp/cron_expression/cron_expression.cpp
+++ b/library/cpp/cron_expression/cron_expression.cpp
@@ -1060,12 +1060,15 @@ private:
}
value = GetField(calendar, ECronField::CF_DAY_OF_MONTH);
+ // FindDay may cross a month/year boundary keeping the same day number (e.g. 'L-1'), check them too
+ const auto prevMonth = calendar.month();
+ const auto prevYear = calendar.year();
updateValue = FindDay(calendar, Target_.GetDayInMonth(), value, GetWeekday(calendar), Target_.GetFlags(), resets, offset);
if (updateValue.Empty()) {
ythrow yexception() << ErrorDateNotExists;
}
- if (value == updateValue) {
+ if (value == updateValue && prevMonth == calendar.month() && prevYear == calendar.year()) {
resets.Set(static_cast<uint32_t>(ECronField::CF_DAY_OF_MONTH));
} else {
continue;