50bool QMilankovicCalendar::isLeapYear(
int year)
const
52 if (year == QCalendar::Unspecified)
58 const auto yeardm = qDivMod<100>(year);
59 if (yeardm.remainder == 0) {
60 const qint16 century = qMod<9>(yeardm.quotient);
61 if (century != 2 && century != 6)
75bool QMilankovicCalendar::dateToJulianDay(
int year,
int month,
int day, qint64 *jd)
const
78 if (!isDateValid(year, month, day))
81 const auto yearDays = yearMonthToYearDays(year, month);
82 const auto centuryYear = qDivMod<100>(yearDays.year);
83 const qint64 fromYear = qDiv<9>(NineCenturies * centuryYear.quotient + 6)
84 + qDiv<100>(LeapCentury * centuryYear.remainder);
85 *jd = fromYear + yearDays.days + day + MilankovicBaseJd;
89QCalendar::YearMonthDay QMilankovicCalendar::julianDayToDate(qint64 jd)
const
91 const auto century9Day = qDivMod<NineCenturies>(9 * (jd - MilankovicBaseJd) - 7);
93 const auto year100Day = qDivMod<LeapCentury>(100 * qDiv<9>(century9Day.remainder) + 99);
95 const auto ymd = dayInYearToYmd(qDiv<100>(year100Day.remainder));
96 const int y = 100 * century9Day.quotient + year100Day.quotient + ymd.year;
97 return QCalendar::YearMonthDay(y > 0 ? y : y - 1, ymd.month, ymd.day);