moved timerange functions to timerange class

This commit is contained in:
itsmattkc
2019-11-17 12:29:09 +09:00
parent cd69bd76b9
commit c6d5fbae8c
2 changed files with 27 additions and 0 deletions
+21
View File
@@ -48,6 +48,27 @@ bool TimeRange::operator==(const TimeRange &r) const
return in() == r.in() && out() == r.out();
}
bool TimeRange::OverlapsWith(const TimeRange &a) const
{
return Overlap(a, *this);
}
TimeRange TimeRange::CombineWith(const TimeRange &a) const
{
return Combine(a, *this);
}
bool TimeRange::Overlap(const TimeRange &a, const TimeRange &b)
{
return !(a.out() < b.in() || a.in() > b.out());
}
TimeRange TimeRange::Combine(const TimeRange &a, const TimeRange &b)
{
return TimeRange(qMin(a.in(), b.in()),
qMax(a.out(), b.out()));
}
void TimeRange::normalize()
{
// If `out` is earlier than `in`, swap them