mirror of
https://github.com/tnodir/fort
synced 2024-11-15 01:47:47 +00:00
UI: DateUtil: Simplify isTimeInPeriod()
This commit is contained in:
parent
0c75c943b6
commit
bf4247b73d
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user