1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ 2 3 #ifndef LEGACYTIMEPERIOD_H 4 #define LEGACYTIMEPERIOD_H 5 6 #include "icinga/i2-icinga.hpp" 7 #include "icinga/timeperiod.hpp" 8 #include "base/dictionary.hpp" 9 #include <boost/date_time/gregorian/gregorian.hpp> 10 11 namespace icinga 12 { 13 14 /** 15 * Implements Icinga 1.x time periods. 16 * 17 * @ingroup icinga 18 */ 19 class LegacyTimePeriod 20 { 21 public: 22 static Array::Ptr ScriptFunc(const TimePeriod::Ptr& tp, double start, double end); 23 24 static bool IsInTimeRange(const tm *begin, const tm *end, int stride, const tm *reference); 25 static void FindNthWeekday(int wday, int n, tm *reference); 26 static int WeekdayFromString(const String& daydef); 27 static int MonthFromString(const String& monthdef); 28 static void ParseTimeSpec(const String& timespec, tm *begin, tm *end, const tm *reference); 29 static void ParseTimeRange(const String& timerange, tm *begin, tm *end, int *stride, const tm *reference); 30 static bool IsInDayDefinition(const String& daydef, const tm *reference); 31 static void ProcessTimeRangeRaw(const String& timerange, const tm *reference, tm *begin, tm *end); 32 static Dictionary::Ptr ProcessTimeRange(const String& timerange, const tm *reference); 33 static void ProcessTimeRanges(const String& timeranges, const tm *reference, const Array::Ptr& result); 34 static Dictionary::Ptr FindNextSegment(const String& daydef, const String& timeranges, const tm *reference); 35 static Dictionary::Ptr FindRunningSegment(const String& daydef, const String& timeranges, const tm *reference); 36 37 private: 38 LegacyTimePeriod(); 39 40 static boost::gregorian::date GetEndOfMonthDay(int year, int month); 41 }; 42 43 } 44 45 #endif /* LEGACYTIMEPERIOD_H */ 46