Skip to content

Commit

Permalink
Fix: "day -X" time specifications are parsed incorrectly
Browse files Browse the repository at this point in the history
fixes #11147
  • Loading branch information
gunnarbeutner committed May 12, 2016
1 parent 7f915db commit 89c7b5a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/icinga/legacytimeperiod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid day in time specification: " + timespec));

if (begin) {
*begin = *reference;
begin->tm_year = year - 1900;
begin->tm_mon = month - 1;
begin->tm_mday = day;
Expand All @@ -159,6 +160,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
}

if (end) {
*end = *reference;
end->tm_year = year - 1900;
end->tm_mon = month - 1;
end->tm_mday = day;
Expand Down Expand Up @@ -191,7 +193,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,

/* Negative days are relative to the next month. */
if (mday < 0) {
end->tm_mday--;
begin->tm_mday = mday * -1 - 1;
begin->tm_mon++;
}
}
Expand All @@ -206,7 +208,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,

/* Negative days are relative to the next month. */
if (mday < 0) {
end->tm_mday--;
end->tm_mday = mday * -1 - 1;
end->tm_mon++;
}
}
Expand Down

0 comments on commit 89c7b5a

Please sign in to comment.