Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qgregoriancalendar_p.h
Go to the documentation of this file.
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
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;
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
57
58#endif // QGREGORIAN_CALENDAR_P_H
virtual QString standaloneMonthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const
Returns the standalone name of the specified month in the chosen locale, using the specified format t...
Definition qlocale.cpp:3030
virtual bool isLeapYear(int year) const =0
Returns true if the specified year is a leap year for this calendar.
virtual bool dateToJulianDay(int year, int month, int day, qint64 *jd) const =0
Computes the Julian day number corresponding to the specified year, month, and day.
virtual QCalendar::YearMonthDay julianDayToDate(qint64 jd) const =0
Computes the year, month, and day in this calendar for the given Julian day number jd.
virtual QString name() const =0
Returns the primary name of the calendar.
virtual QString monthName(const QLocale &locale, int month, int year, QLocale::FormatType format) const
Returns the name of the specified month in the given year for the chosen locale, using the given form...
Definition qlocale.cpp:2995
\inmodule QtCore \reentrant
Definition qdatetime.h:27
The QGregorianCalendar class implements the Gregorian calendar.
The QRomanCalendar class is a shared base for calendars based on the ancient Roman calendar.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QDate date
[1]
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum format
long long qint64
Definition qtypes.h:55