| 155 | } |
| 156 | |
| 157 | bool TimeTable::SetOpeningTime(osmoh::Timespan const & span) |
| 158 | { |
| 159 | if (IsTwentyFourHours()) |
| 160 | return false; |
| 161 | |
| 162 | m_openingTime = span; |
| 163 | osmoh::TTimespans excludeTime; |
| 164 | for (auto const & excludeSpan : GetExcludeTime()) |
| 165 | { |
| 166 | auto const openingTimeStart = GetOpeningTime().GetStart().GetHourMinutes().GetDuration(); |
| 167 | auto const openingTimeEnd = GetOpeningTime().GetEnd().GetHourMinutes().GetDuration(); |
| 168 | auto const excludeSpanStart = excludeSpan.GetStart().GetHourMinutes().GetDuration(); |
| 169 | auto const excludeSpanEnd = excludeSpan.GetEnd().GetHourMinutes().GetDuration(); |
| 170 | |
| 171 | if (!GetOpeningTime().HasExtendedHours() && |
| 172 | (excludeSpanStart < openingTimeStart || openingTimeEnd < excludeSpanEnd)) |
| 173 | continue; |
| 174 | |
| 175 | excludeTime.push_back(excludeSpan); |
| 176 | } |
| 177 | |
| 178 | m_excludeTime.swap(excludeTime); |
| 179 | return true; |
| 180 | } |
| 181 | |
| 182 | bool TimeTable::CanAddExcludeTime() const |
| 183 | { |