MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / IsInRange

Method IsInRange

include/util/opening_hours.hpp:215–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213 OpeningHours() : modifier(open) {}
214
215 bool IsInRange(const struct tm &time) const
216 {
217 bool use_curr_day = true; // the first matching time uses the current day
218 bool use_next_day = false; // the first matching time uses the next day
219 return (!times.empty() || !weekdays.empty() || !monthdays.empty())
220 // the value is in range if time is not specified or is in any time range
221 // (also modifies use_curr_day and use_next_day flags to handle overnight day ranges,
222 // e.g. for 22:00-03:00 and 2am -> use_curr_day = false and use_next_day = true)
223 && (times.empty() ||
224 std::any_of(times.begin(),
225 times.end(),
226 [&time, &use_curr_day, &use_next_day](const auto &x)
227 { return x.IsInRange(time, use_curr_day, use_next_day); }))
228 // .. and if weekdays are not specified or matches weekdays range
229 && (weekdays.empty() ||
230 std::any_of(weekdays.begin(),
231 weekdays.end(),
232 [&time, use_curr_day, use_next_day](const auto &x)
233 { return x.IsInRange(time, use_curr_day, use_next_day); }))
234 // .. and if month-day ranges are not specified or is in any month-day range
235 && (monthdays.empty() ||
236 std::any_of(monthdays.begin(),
237 monthdays.end(),
238 [&time, use_curr_day, use_next_day](const auto &x)
239 { return x.IsInRange(time, use_curr_day, use_next_day); }));
240 }
241
242 std::vector<TimeSpan> times;
243 std::vector<WeekdayRange> weekdays;

Callers 1

CheckOpeningHoursFunction · 0.45

Calls 3

emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected