summaryrefslogtreecommitdiffstats
path: root/lib/icinga/legacytimeperiod.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:34:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:34:54 +0000
commit0915b3ef56dfac3113cce55a59a5765dc94976be (patch)
treea8fea11d50b4f083e1bf0f90025ece7f0824784a /lib/icinga/legacytimeperiod.hpp
parentInitial commit. (diff)
downloadicinga2-0915b3ef56dfac3113cce55a59a5765dc94976be.tar.xz
icinga2-0915b3ef56dfac3113cce55a59a5765dc94976be.zip
Adding upstream version 2.13.6.upstream/2.13.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--lib/icinga/legacytimeperiod.hpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/icinga/legacytimeperiod.hpp b/lib/icinga/legacytimeperiod.hpp
new file mode 100644
index 0000000..001eb5c
--- /dev/null
+++ b/lib/icinga/legacytimeperiod.hpp
@@ -0,0 +1,45 @@
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
+
+#ifndef LEGACYTIMEPERIOD_H
+#define LEGACYTIMEPERIOD_H
+
+#include "icinga/i2-icinga.hpp"
+#include "icinga/timeperiod.hpp"
+#include "base/dictionary.hpp"
+#include <boost/date_time/gregorian/gregorian.hpp>
+
+namespace icinga
+{
+
+/**
+ * Implements Icinga 1.x time periods.
+ *
+ * @ingroup icinga
+ */
+class LegacyTimePeriod
+{
+public:
+ static Array::Ptr ScriptFunc(const TimePeriod::Ptr& tp, double start, double end);
+
+ static bool IsInTimeRange(const tm *begin, const tm *end, int stride, const tm *reference);
+ static void FindNthWeekday(int wday, int n, tm *reference);
+ static int WeekdayFromString(const String& daydef);
+ static int MonthFromString(const String& monthdef);
+ static void ParseTimeSpec(const String& timespec, tm *begin, tm *end, const tm *reference);
+ static void ParseTimeRange(const String& timerange, tm *begin, tm *end, int *stride, const tm *reference);
+ static bool IsInDayDefinition(const String& daydef, const tm *reference);
+ static void ProcessTimeRangeRaw(const String& timerange, const tm *reference, tm *begin, tm *end);
+ static Dictionary::Ptr ProcessTimeRange(const String& timerange, const tm *reference);
+ static void ProcessTimeRanges(const String& timeranges, const tm *reference, const Array::Ptr& result);
+ static Dictionary::Ptr FindNextSegment(const String& daydef, const String& timeranges, const tm *reference);
+ static Dictionary::Ptr FindRunningSegment(const String& daydef, const String& timeranges, const tm *reference);
+
+private:
+ LegacyTimePeriod();
+
+ static boost::gregorian::date GetEndOfMonthDay(int year, int month);
+};
+
+}
+
+#endif /* LEGACYTIMEPERIOD_H */