From bf4247b73dd8e4d404251809c4d9b620ce0ca275 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sun, 13 Oct 2024 15:42:05 +0500 Subject: [PATCH] UI: DateUtil: Simplify isTimeInPeriod() --- src/ui/util/dateutil.cpp | 8 ++------ src/ui/util/dateutil.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ui/util/dateutil.cpp b/src/ui/util/dateutil.cpp index 8b524f13..5a852c53 100644 --- a/src/ui/util/dateutil.cpp +++ b/src/ui/util/dateutil.cpp @@ -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); } diff --git a/src/ui/util/dateutil.h b/src/ui/util/dateutil.h index ad2e1dc1..9d029083 100644 --- a/src/ui/util/dateutil.h +++ b/src/ui/util/dateutil.h @@ -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