7#include <QtCore/qdatetime.h>
14static_assert(qDivMod<2>(-86400).quotient == -43200);
15static_assert(qDivMod<2>(-86400).remainder == 0);
16static_assert(qDivMod<86400>(-86400).quotient == -1);
17static_assert(qDivMod<86400>(-86400).remainder == 0);
18static_assert(qDivMod<86400>(-86401).quotient == -2);
19static_assert(qDivMod<86400>(-86401).remainder == 86399);
20static_assert(qDivMod<86400>(-100000).quotient == -2);
21static_assert(qDivMod<86400>(-100000).remainder == 72800);
22static_assert(qDivMod<86400>(-172799).quotient == -2);
23static_assert(qDivMod<86400>(-172799).remainder == 1);
24static_assert(qDivMod<86400>(-172800).quotient == -2);
25static_assert(qDivMod<86400>(-172800).remainder == 0);
74 return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
80 if (month < 1 || month > 12)
86 return 30 | ((month & 1) ^ (month >> 3));
91 return year && 0 < day && day <=
monthLength(month, year);
96 return int(qMod<7>(jd) + 1);
115 const int y = year - (year < 0 ? 800 : 801);
116 return qMod<7>(
y + qDiv<4>(
y) - qDiv<100>(
y) + qDiv<400>(
y)) + 1;
136 static_assert((400 * 365 + 97) % 7 == 0);
143 int res = (year < 1970
144 ? 2400 - (2000 - (year < 0 ? year + 1 : year)) % 400
145 : year > 2399 ? 2000 + (year - 2000) % 400 : year);
148 const int lastTwo =
res % 100;
150 Q_ASSERT(lastTwo && !(lastTwo & ~31));
152 static constexpr int usual[] = { 2198, 2199, 2098, 2099, 2399, 2298, 2299 };
153 static constexpr int leaps[] = { 2396, 2284, 2296, 2184, 2196, 2084, 2096 };
187 const qint64 y = yearDays.year;
188 const qint64 fromYear = 365 *
y + qDiv<4>(
y) - qDiv<100>(
y) + qDiv<400>(
y);
189 return fromYear + yearDays.days + day +
BaseJd;
195 const qint64 century = qDiv<FourCenturies>(4 * dayNumber - 1);
196 const int dayInCentury = dayNumber - qDiv<4>(
FourCenturies * century);
198 const int yearInCentury = qDiv<FourYears>(4 * dayInCentury - 1);
199 const int dayInYear = dayInCentury - qDiv<4>(
FourYears * yearInCentury);
200 const int m = qDiv<FiveMonths>(5 * dayInYear - 3);
203 const int yearOffset =
m < 10 ? 0 : 1;
205 const int y = 100 * century + yearInCentury + yearOffset;
206 const int month =
m + 3 - 12 * yearOffset;
207 const int day = dayInYear - qDiv<5>(
FiveMonths *
m + 2);
virtual int dayOfWeek(qint64 jd) const
Returns the day of the week for the given Julian Day Number jd.
\inmodule QtCore \reentrant
int month() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int day() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int year() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static std::optional< qint64 > julianFromParts(int year, int month, int day)
static int yearStartWeekDay(int year)
QCalendar::YearMonthDay julianDayToDate(qint64 jd) const override
Computes the year, month, and day in this calendar for the given Julian day number jd.
static int monthLength(int month, int year)
static QStringList nameList()
static bool leapTest(int year)
bool dateToJulianDay(int year, int month, int day, qint64 *jd) const override
Computes the Julian day number corresponding to the specified year, month, and day.
QString name() const override
Returns the primary name of the calendar.
static QCalendar::YearMonthDay partsFromJulian(qint64 jd)
static bool validParts(int year, int month, int day)
static int yearSharingWeekDays(QDate date)
bool isLeapYear(int year) const override
Returns true if the specified year is a leap year for this calendar.
static int weekDayOfJulian(qint64 jd)
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr qint64 LeapDayGregorian1Bce
constexpr auto yearMonthToYearDays(int year, int month)
constexpr unsigned FourYears
constexpr unsigned FiveMonths
Combined button and popup list for selecting options.
constexpr unsigned FourCenturies
#define QStringLiteral(str)