51bool QMilankovicCalendar::isLeapYear(
int year)
const
53 if (year == QCalendar::Unspecified)
59 const auto yeardm = qDivMod<100>(year);
60 if (yeardm.remainder == 0) {
61 const qint16 century = qMod<9>(yeardm.quotient);
62 if (century != 2 && century != 6)
76bool QMilankovicCalendar::dateToJulianDay(
int year,
int month,
int day, qint64 *jd)
const
79 if (!isDateValid(year, month, day))
82 const auto yearDays = yearMonthToYearDays(year, month);
83 const auto centuryYear = qDivMod<100>(yearDays.year);
84 const qint64 fromYear = qDiv<9>(NineCenturies * centuryYear.quotient + 6)
85 + qDiv<100>(LeapCentury * centuryYear.remainder);
86 *jd = fromYear + yearDays.days + day + MilankovicBaseJd;
90QCalendar::YearMonthDay QMilankovicCalendar::julianDayToDate(qint64 jd)
const
92 const auto century9Day = qDivMod<NineCenturies>(9 * (jd - MilankovicBaseJd) - 7);
94 const auto year100Day = qDivMod<LeapCentury>(100 * qDiv<9>(century9Day.remainder) + 99);
96 const auto ymd = dayInYearToYmd(qDiv<100>(year100Day.remainder));
97 const int y = 100 * century9Day.quotient + year100Day.quotient + ymd.year;
98 return QCalendar::YearMonthDay(y > 0 ? y : y - 1, ymd.month, ymd.day);