mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -41,22 +41,20 @@ bool FixTimeSpans(osmoh::Timespan openingTime, osmoh::TTimespans & spans)
|
||||
return true;
|
||||
|
||||
for (auto & span : spans)
|
||||
{
|
||||
if (span.HasExtendedHours())
|
||||
span.GetEnd().GetHourMinutes().AddDuration(24_h);
|
||||
}
|
||||
|
||||
std::sort(std::begin(spans), std::end(spans),
|
||||
[](osmoh::Timespan const & s1, osmoh::Timespan const s2) {
|
||||
auto const start1 = s1.GetStart().GetHourMinutes();
|
||||
auto const start2 = s2.GetStart().GetHourMinutes();
|
||||
std::sort(std::begin(spans), std::end(spans), [](osmoh::Timespan const & s1, osmoh::Timespan const s2)
|
||||
{
|
||||
auto const start1 = s1.GetStart().GetHourMinutes();
|
||||
auto const start2 = s2.GetStart().GetHourMinutes();
|
||||
|
||||
// If two spans start at the same point the longest span should be leftmost.
|
||||
if (start1 == start2)
|
||||
return SpanLength(s1) > SpanLength(s2);
|
||||
// If two spans start at the same point the longest span should be leftmost.
|
||||
if (start1 == start2)
|
||||
return SpanLength(s1) > SpanLength(s2);
|
||||
|
||||
return start1 < start2;
|
||||
});
|
||||
return start1 < start2;
|
||||
});
|
||||
|
||||
osmoh::TTimespans result{spans.front()};
|
||||
for (size_t i = 1, j = 0; i < spans.size(); ++i)
|
||||
@@ -91,17 +89,14 @@ bool FixTimeSpans(osmoh::Timespan openingTime, osmoh::TTimespans & spans)
|
||||
return false;
|
||||
|
||||
for (auto & span : result)
|
||||
{
|
||||
if (span.HasExtendedHours())
|
||||
span.GetEnd().GetHourMinutes().AddDuration(-24_h);
|
||||
}
|
||||
|
||||
spans.swap(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
osmoh::Timespan GetLongetsOpenSpan(osmoh::Timespan const & openingTime,
|
||||
osmoh::TTimespans const & excludeTime)
|
||||
osmoh::Timespan GetLongetsOpenSpan(osmoh::Timespan const & openingTime, osmoh::TTimespans const & excludeTime)
|
||||
{
|
||||
if (excludeTime.empty())
|
||||
return openingTime;
|
||||
@@ -116,7 +111,7 @@ osmoh::Timespan GetLongetsOpenSpan(osmoh::Timespan const & openingTime,
|
||||
osmoh::Timespan lastSpan{excludeTime.back().GetEnd(), openingTime.GetEnd()};
|
||||
return SpanLength(longestSpan) > SpanLength(lastSpan) ? longestSpan : lastSpan;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
namespace editor
|
||||
{
|
||||
@@ -129,15 +124,8 @@ TimeTable TimeTable::GetPredefinedTimeTable()
|
||||
{
|
||||
TimeTable tt;
|
||||
tt.m_isTwentyFourHours = true;
|
||||
tt.m_weekdays = {
|
||||
osmoh::Weekday::Sunday,
|
||||
osmoh::Weekday::Monday,
|
||||
osmoh::Weekday::Tuesday,
|
||||
osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday,
|
||||
osmoh::Weekday::Friday,
|
||||
osmoh::Weekday::Saturday
|
||||
};
|
||||
tt.m_weekdays = {osmoh::Weekday::Sunday, osmoh::Weekday::Monday, osmoh::Weekday::Tuesday, osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday, osmoh::Weekday::Friday, osmoh::Weekday::Saturday};
|
||||
|
||||
tt.m_openingTime = tt.GetPredefinedOpeningTime();
|
||||
|
||||
@@ -180,7 +168,8 @@ bool TimeTable::SetOpeningTime(osmoh::Timespan const & span)
|
||||
auto const excludeSpanStart = excludeSpan.GetStart().GetHourMinutes().GetDuration();
|
||||
auto const excludeSpanEnd = excludeSpan.GetEnd().GetHourMinutes().GetDuration();
|
||||
|
||||
if (!GetOpeningTime().HasExtendedHours() && (excludeSpanStart < openingTimeStart || openingTimeEnd < excludeSpanEnd))
|
||||
if (!GetOpeningTime().HasExtendedHours() &&
|
||||
(excludeSpanStart < openingTimeStart || openingTimeEnd < excludeSpanEnd))
|
||||
continue;
|
||||
|
||||
excludeTime.push_back(excludeSpan);
|
||||
@@ -193,8 +182,7 @@ bool TimeTable::SetOpeningTime(osmoh::Timespan const & span)
|
||||
bool TimeTable::CanAddExcludeTime() const
|
||||
{
|
||||
auto copy = *this;
|
||||
return copy.AddExcludeTime(GetPredefinedExcludeTime()) &&
|
||||
copy.GetExcludeTime().size() == GetExcludeTime().size() + 1;
|
||||
return copy.AddExcludeTime(GetPredefinedExcludeTime()) && copy.GetExcludeTime().size() == GetExcludeTime().size() + 1;
|
||||
}
|
||||
|
||||
bool TimeTable::AddExcludeTime(osmoh::Timespan const & span)
|
||||
@@ -294,15 +282,9 @@ TimeTableSet::TimeTableSet()
|
||||
|
||||
OpeningDays TimeTableSet::GetUnhandledDays() const
|
||||
{
|
||||
OpeningDays days = {
|
||||
osmoh::Weekday::Sunday,
|
||||
osmoh::Weekday::Monday,
|
||||
osmoh::Weekday::Tuesday,
|
||||
osmoh::Weekday::Wednesday,
|
||||
osmoh::Weekday::Thursday,
|
||||
osmoh::Weekday::Friday,
|
||||
osmoh::Weekday::Saturday
|
||||
};
|
||||
OpeningDays days = {osmoh::Weekday::Sunday, osmoh::Weekday::Monday, osmoh::Weekday::Tuesday,
|
||||
osmoh::Weekday::Wednesday, osmoh::Weekday::Thursday, osmoh::Weekday::Friday,
|
||||
osmoh::Weekday::Saturday};
|
||||
|
||||
for (auto const & tt : *this)
|
||||
for (auto const day : tt.GetOpeningDays())
|
||||
@@ -325,9 +307,8 @@ TimeTable TimeTableSet::GetComplementTimeTable() const
|
||||
|
||||
bool TimeTableSet::IsTwentyFourPerSeven() const
|
||||
{
|
||||
return GetUnhandledDays().empty() &&
|
||||
std::all_of(std::begin(m_table), std::end(m_table),
|
||||
[](TimeTable const & tt) { return tt.IsTwentyFourHours(); });
|
||||
return GetUnhandledDays().empty() && std::all_of(std::begin(m_table), std::end(m_table),
|
||||
[](TimeTable const & tt) { return tt.IsTwentyFourHours(); });
|
||||
}
|
||||
|
||||
bool TimeTableSet::Append(TimeTable const & tt)
|
||||
@@ -392,5 +373,5 @@ bool TimeTableSet::UpdateByIndex(TimeTableSet & ttSet, size_t const index)
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namspace ui
|
||||
} // namespace editor
|
||||
} // namespace ui
|
||||
} // namespace editor
|
||||
|
||||
Reference in New Issue
Block a user