UI: DateUtil: Simplify isTimeInPeriod()

This commit is contained in:
Nodir Temirkhodjaev 2024-10-13 15:42:05 +05:00
parent 0c75c943b6
commit bf4247b73d
2 changed files with 3 additions and 7 deletions

View File

@ -152,11 +152,7 @@ QTime DateUtil::parseTime(const QString &time)
return QTime(hour, minute);
}
bool DateUtil::isTimeInPeriod(QTime time, QTime periodFrom, QTime periodTo)
bool DateUtil::isTimeInPeriod(QTime time, QTime from, QTime to)
{
const int x = time.msecsSinceStartOfDay();
const int from = periodFrom.msecsSinceStartOfDay();
const int to = periodTo.msecsSinceStartOfDay();
return (from <= to) ? (x >= from && x < to) : (x >= from || x < to);
return (from <= to) ? (time >= from && time < to) : (time >= from || time < to);
}

View File

@ -42,7 +42,7 @@ public:
static QTime parseTime(const QString &time);
static bool isTimeInPeriod(QTime time, QTime periodFrom, QTime periodTo);
static bool isTimeInPeriod(QTime time, QTime from, QTime to);
};
#endif // DATEUTIL_H