2 * @brief time related functions. Week module
4 * @copyright Copyright © 2001-2009 by Intra2net AG
6 * @contact info@intra2net.com
20 * @brief represents some days of a week.
26 /// Bitset storing the active days. Zero is Sunday.
28 /// Flag to indicate if this Week is valid
32 enum WeekDay { Su=0, Mo=1, Tu=2, We=3, Th=4, Fr=5, Sa=6, _WeekDay_END=7 };
35 Week(const std::string& daystring);
36 Week(const std::bitset<7> &_days);
38 bool is_valid() const;
42 operator std::bitset<7>() const
45 bool set(const std::string& daystring);
46 bool set(const WeekDay day, bool value=true);
48 bool get(WeekDay day) const;
49 bool is_set(WeekDay day) const;
52 bool none_set() const;
54 unsigned int days_till_set(WeekDay day) const;
55 unsigned int days_since_set(WeekDay day) const;
57 std::string get_daystring() const;
58 std::string get_displaystring() const;
59 std::string get_netfilterstring() const;
61 static std::string get_day_display(WeekDay day);
62 static std::string get_english_display(WeekDay day);
64 // some operators for convenience:
66 Week& operator&=(const Week& rhs)
72 Week& operator|=(const Week& rhs)
78 Week& operator^=(const Week& rhs)
84 bool operator==(const Week& rhs)
86 return Days == rhs.Days;
89 bool operator!=(const Week& rhs)
91 return Days != rhs.Days;
97 * @brief delivers a week containing the days which are in both weeks.
98 * @param lhs first week.
99 * @param rhs second week.
100 * @return week which has only those days which are in both weeks.
102 inline Week operator&(const Week& lhs, const Week& rhs)
104 I2n::Time::Week result(lhs);
105 return result &= rhs;
110 * @brief delivers a week containing the days which are at least in one of both weeks.
111 * @param lhs first week.
112 * @param rhs second week.
113 * @return week which has only those days which are at least in one of both weeks.
115 inline Week operator|(const Week& lhs, const Week& rhs)
117 I2n::Time::Week result(lhs);
118 return result |= rhs;
123 * @brief delivers a week containing the days which are in only one of both weeks.
124 * @param lhs first week.
125 * @param rhs second week.
126 * @return week which has only those days which are in only one of both weeks.
128 inline Week operator^(const Week& lhs, const Week& rhs)
130 I2n::Time::Week result(lhs);
131 return result ^= rhs;