]> granicus.if.org Git - icinga2/commitdiff
Do not add the old timeperiod segment, if we cut it in the middle 6311/head
authorPhilipp Dallig <philipp.dallig@gmail.com>
Wed, 16 May 2018 10:04:38 +0000 (12:04 +0200)
committerPhilipp Dallig <philipp.dallig@gmail.com>
Wed, 16 May 2018 10:04:38 +0000 (12:04 +0200)
lib/icinga/timeperiod.cpp

index 97183223e253a808a01ed6b6a509c00c07456b5d..94a57c30bf186fe96486dd5bfb50deee0123ffa6 100644 (file)
@@ -142,12 +142,12 @@ void TimePeriod::RemoveSegment(double begin, double end)
        for (const Dictionary::Ptr& segment : segments) {
                /* Fully contained in the specified range? */
                if (segment->Get("begin") >= begin && segment->Get("end") <= end)
+                       // Don't add the old segment, because the segment is fully contained into our range
                        continue;
 
                /* Not overlapping at all? */
                if (segment->Get("end") < begin || segment->Get("begin") > end) {
                        newSegments->Add(segment);
-
                        continue;
                }
 
@@ -162,6 +162,8 @@ void TimePeriod::RemoveSegment(double begin, double end)
                                { "begin", end },
                                { "end", segment->Get("end") }
                        }));
+                       // Don't add the old segment, because we have now two new segments and a gap between
+                       continue;
                }
 
                /* Adjust the begin/end timestamps so as to not overlap with the specified range. */