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
22QT_BEGIN_NAMESPACE
23
24class 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.
28public:
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
38 // Names of months (implemented in qlocale.cpp):
39 QString monthName(const QLocale &locale, int month, int year,
40 QLocale::FormatType format) const override;
41 QString standaloneMonthName(const QLocale &locale, int month, int year,
42 QLocale::FormatType format) const override;
43
44 // Static optimized versions for the benefit of QDate:
45 static int weekDayOfJulian(qint64 jd);
46 static bool leapTest(int year);
47 static int monthLength(int month, int year);
48 static bool validParts(int year, int month, int day);
49 static QCalendar::YearMonthDay partsFromJulian(qint64 jd);
50 static std::optional<qint64> julianFromParts(int year, int month, int day);
51 // Used internally:
52 static int yearStartWeekDay(int year);
53 static int yearSharingWeekDays(QDate date);
54};
55
56QT_END_NAMESPACE
57
58#endif // QGREGORIAN_CALENDAR_P_H
59

source code of qtbase/src/corelib/time/qgregoriancalendar_p.h