Returns a vector of Weekdays with no gaps and with Sunday as the last day. Exampls: su, mo, we -> mo, we, su; su, mo, fr, sa -> fr, sa, su, mo.
| 90 | // su, mo, we -> mo, we, su; |
| 91 | // su, mo, fr, sa -> fr, sa, su, mo. |
| 92 | std::vector<osmoh::Weekday> RemoveInversion(editor::ui::OpeningDays const & days) |
| 93 | { |
| 94 | std::vector<osmoh::Weekday> result(begin(days), end(days)); |
| 95 | if ((NextWeekdayNumber(result.back()) != WeekdayNumber(result.front()) && result.back() != osmoh::Weekday::Sunday) || |
| 96 | result.size() < 2) |
| 97 | return result; |
| 98 | |
| 99 | auto inversion = adjacent_find(begin(result), end(result), [](osmoh::Weekday const a, osmoh::Weekday const b) |
| 100 | { return NextWeekdayNumber(a) != WeekdayNumber(b); }); |
| 101 | |
| 102 | if (inversion != end(result)) |
| 103 | rotate(begin(result), ++inversion, end(result)); |
| 104 | |
| 105 | if (result.front() == osmoh::Weekday::Sunday) |
| 106 | rotate(begin(result), begin(result) + 1, end(result)); |
| 107 | |
| 108 | return result; |
| 109 | } |
| 110 | |
| 111 | using Weekdays = std::vector<osmoh::Weekday>; |
| 112 |
no test coverage detected