From 0ace7df8390afe16e42162d97463b04511d6783b Mon Sep 17 00:00:00 2001 From: Sergey Magidovich Date: Tue, 7 Jun 2016 14:22:24 +0300 Subject: Open end is now handled. --- editor/editor_tests/ui2oh_test.cpp | 17 +++++++++++++++++ editor/ui2oh.cpp | 4 ++++ 2 files changed, 21 insertions(+) (limited to 'editor') diff --git a/editor/editor_tests/ui2oh_test.cpp b/editor/editor_tests/ui2oh_test.cpp index f11d75d63f..7d58ae87b1 100644 --- a/editor/editor_tests/ui2oh_test.cpp +++ b/editor/editor_tests/ui2oh_test.cpp @@ -309,6 +309,23 @@ UNIT_TEST(OpeningHours2TimeTableSet_off) } } +UNIT_TEST(OpeningHours2TimeTableSet_plus) +{ + OpeningHours oh("Mo-Su 11:00+"); + TEST(oh.IsValid(), ()); + + TimeTableSet tts; + + TEST(MakeTimeTableSet(oh, tts), ()); + TEST_EQUAL(tts.Size(), 1, ()); + + auto const tt = tts.Get(0); + TEST_EQUAL(tts.GetUnhandledDays(), TOpeningDays(), ()); + + TEST_EQUAL(tt.GetOpeningTime().GetStart().GetHourMinutes().GetHoursCount(), 11, ()); + TEST_EQUAL(tt.GetOpeningTime().GetEnd().GetHourMinutes().GetHoursCount(), 24, ()); +} + UNIT_TEST(TimeTableSt2OpeningHours) { { diff --git a/editor/ui2oh.cpp b/editor/ui2oh.cpp index 19e0abfd79..d7f3b317f9 100644 --- a/editor/ui2oh.cpp +++ b/editor/ui2oh.cpp @@ -42,6 +42,10 @@ void SetUpTimeTable(osmoh::TTimespans spans, editor::ui::TimeTable & tt) { using namespace osmoh; + // Expand plus: 13:15+ -> 13:15-24:00. + for (auto & span : spans) + span.ExpandPlus(); + sort(begin(spans), end(spans), [](Timespan const & a, Timespan const & b) { auto const start1 = a.GetStart().GetHourMinutes().GetDuration(); -- cgit v1.2.3