| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QGREGORIAN_CALENDAR_P_H |
| 5 | #define QGREGORIAN_CALENDAR_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of calendar implementations. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qromancalendar_p.h" |
| 19 | |
| 20 | #include <optional> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class Q_CORE_EXPORT QGregorianCalendar : public QRomanCalendar |
| 25 | { |
| 26 | // TODO: provide static methods, called by the overrides, that can be called |
| 27 | // directly by QDate to optimize various parts. |
| 28 | public: |
| 29 | // Calendar property: |
| 30 | QString name() const override; |
| 31 | static QStringList nameList(); |
| 32 | // Date queries: |
| 33 | bool isLeapYear(int year) const override; |
| 34 | // Julian Day conversions: |
| 35 | bool dateToJulianDay(int year, int month, int day, qint64 *jd) const override; |
| 36 | QCalendar::YearMonthDay julianDayToDate(qint64 jd) const override; |
| 37 | qint64 matchCenturyToWeekday(const QCalendar::YearMonthDay &parts, int dow) const override; |
| 38 | |
| 39 | // Static optimized versions for the benefit of QDate: |
| 40 | static int weekDayOfJulian(qint64 jd); |
| 41 | static bool leapTest(int year); |
| 42 | static int monthLength(int month, int year); |
| 43 | static bool validParts(int year, int month, int day); |
| 44 | static QCalendar::YearMonthDay partsFromJulian(qint64 jd); |
| 45 | static std::optional<qint64> julianFromParts(int year, int month, int day); |
| 46 | // Used internally: |
| 47 | static int yearStartWeekDay(int year); |
| 48 | static int yearSharingWeekDays(QDate date); |
| 49 | }; |
| 50 | |
| 51 | QT_END_NAMESPACE |
| 52 | |
| 53 | #endif // QGREGORIAN_CALENDAR_P_H |
| 54 | |