]> granicus.if.org Git - icinga2/commitdiff
Fix: "day -X" time specifications are parsed incorrectly
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 11 May 2016 07:23:55 +0000 (09:23 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 12 May 2016 09:09:49 +0000 (11:09 +0200)
fixes #11147

lib/icinga/legacytimeperiod.cpp

index 267fb67f2c39b069fcb9dbbb468cfd6bffd9856a..2c08394e95eebe231e6c7311638fb953dc233e2f 100644 (file)
@@ -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;
@@ -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;
@@ -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++;
                        }
                }
@@ -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++;
                        }
                }