added catpacks tests

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-08-27 23:40:32 +03:00
parent 9110fbf282
commit 07d8598638
4 changed files with 92 additions and 7 deletions

View File

@ -99,18 +99,22 @@ QDate ensureDay(int year, int month, int day)
QString JsonCatPack::path()
{
const QDate now = QDate::currentDate();
return path(QDate::currentDate());
}
QString JsonCatPack::path(QDate now)
{
for (auto var : m_variants) {
QDate startDate = ensureDay(now.year(), var.startTime.month, var.startTime.day);
QDate endDate = ensureDay(now.year(), var.endTime.month, var.endTime.day);
if (startDate > endDate) { // it's spans over multiple years
if (endDate <= now) // end date is in the past so jump one year into the future for endDate
if (endDate < now) // end date is in the past so jump one year into the future for endDate
endDate = endDate.addYears(1);
else // end date is in the future so jump one year into the past for startDate
startDate = startDate.addYears(-1);
}
if (startDate >= now && now >= endDate)
if (startDate <= now && now <= endDate)
return var.path;
}
return m_defaultPath;