Added more options for variants planing

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-07-02 13:34:04 +03:00
parent 7ac2a23bc8
commit 7579fff532
3 changed files with 9 additions and 7 deletions

View File

@ -99,11 +99,13 @@ JsonCatPack::JsonCatPack(QFileInfo& manifestInfo) : BasicCatPack(manifestInfo.di
QString JsonCatPack::path()
{
const QDateTime now = QDateTime::currentDateTime();
const QDate now = QDate::currentDate();
for (auto var : m_variants) {
QDateTime startDate(QDate(now.date().year(), var.startTime.mounth, var.startTime.day), QTime(0, 0));
QDateTime endDate(QDate(now.date().year(), var.endTime.mounth, var.endTime.day), QTime(0, 0));
if (startDate.daysTo(now) > 0 && now.daysTo(endDate) > 0)
QDate startDate(now.year(), var.startTime.month, var.startTime.day);
QDate endDate(now.year(), var.endTime.month, var.endTime.day);
if (startDate.daysTo(endDate) < 0) // in this case end date should be next year
endDate = endDate.addYears(1);
if (startDate.daysTo(now) >= 0 && now.daysTo(endDate) >= 0)
return var.path;
}
return m_defaultPath;