Simplifications in QJalaliCalendar

Change-Id: I5e777453833dd1604fc05afb3bd06d5dd5a49dec
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
This commit is contained in:
Edward Welbourne 2024-08-16 16:30:55 +02:00
parent cd442e439b
commit d6025aa054

View File

@ -96,7 +96,7 @@ bool QJalaliCalendar::isLeapYear(int year) const
if (year == QCalendar::Unspecified)
return false;
if (year < 0)
year++;
++year;
return qMod<2820>((year + 2346) * 683) < 683;
}
@ -138,7 +138,7 @@ QCalendar::YearMonthDay QJalaliCalendar::julianDayToDate(qint64 jd) const
int year = yearInCycle + 475 + c * cycleYears;
int day = jd - firstDayOfYear(yearInCycle, c) + 1;
if (day > daysInYear(year <= 0 ? year - 1 : year)) {
year++;
++year;
day = 1;
}
if (year <= 0)
@ -155,11 +155,16 @@ QCalendar::YearMonthDay QJalaliCalendar::julianDayToDate(qint64 jd) const
int QJalaliCalendar::daysInMonth(int month, int year) const
{
if (year && month > 0 && month <= 12)
return month < 7 ? 31 : (month < 12 || year == QCalendar::Unspecified
|| isLeapYear(year)) ? 30 : 29;
if (!year || month < 1 || month > 12)
return 0;
return 0;
if (month < 7)
return 31;
if (month < 12 || year == QCalendar::Unspecified || isLeapYear(year))
return 30;
return 29;
}
const QCalendarLocale *QJalaliCalendar::localeMonthIndexData() const