Warning, file /include/QtCore/qcalendar.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QCALENDAR_H
0005 #define QCALENDAR_H
0006
0007 #include <limits>
0008
0009 #include <QtCore/qglobal.h>
0010 #include <QtCore/qlocale.h>
0011 #include <QtCore/qstring.h>
0012 #include <QtCore/qstringview.h>
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 QT_BEGIN_NAMESPACE
0048
0049 class QCalendarBackend;
0050 class QDate;
0051
0052 class Q_CORE_EXPORT QCalendar
0053 {
0054 Q_GADGET
0055 public:
0056
0057 enum : int { Unspecified = (std::numeric_limits<int>::min)() };
0058 struct YearMonthDay
0059 {
0060 YearMonthDay() = default;
0061 YearMonthDay(int y, int m = 1, int d = 1) : year(y), month(m), day(d) {}
0062
0063 bool isValid() const
0064 { return month != Unspecified && day != Unspecified; }
0065
0066
0067 int year = Unspecified;
0068 int month = Unspecified;
0069 int day = Unspecified;
0070 };
0071
0072 enum class System
0073 {
0074 Gregorian,
0075 #ifndef QT_BOOTSTRAPPED
0076 Julian = 8,
0077 Milankovic = 9,
0078 #endif
0079
0080
0081 #if QT_CONFIG(jalalicalendar)
0082 Jalali = 10,
0083 #endif
0084 #if QT_CONFIG(islamiccivilcalendar)
0085 IslamicCivil = 11,
0086
0087
0088
0089 #endif
0090
0091 Last = 11,
0092 User = -1
0093 };
0094
0095
0096 Q_ENUM(System)
0097 class SystemId
0098 {
0099 size_t id;
0100 friend class QCalendarBackend;
0101 constexpr bool isInEnum() const { return id <= size_t(QCalendar::System::Last); }
0102 constexpr explicit SystemId(QCalendar::System e) : id(size_t(e)) { }
0103 constexpr explicit SystemId(size_t i) : id(i) { }
0104
0105 public:
0106 constexpr SystemId() : id(~size_t(0)) {}
0107 constexpr size_t index() const noexcept { return id; }
0108 constexpr bool isValid() const noexcept { return ~id; }
0109 };
0110
0111 explicit QCalendar();
0112 explicit QCalendar(System system);
0113 #if QT_CORE_REMOVED_SINCE(6, 4)
0114 explicit QCalendar(QLatin1StringView name);
0115 explicit QCalendar(QStringView name);
0116 #endif
0117 explicit QCalendar(QAnyStringView name);
0118 explicit QCalendar(SystemId id);
0119
0120
0121 bool isValid() const { return d_ptr != nullptr; }
0122
0123
0124 int daysInMonth(int month, int year = Unspecified) const;
0125 int daysInYear(int year) const;
0126 int monthsInYear(int year) const;
0127 bool isDateValid(int year, int month, int day) const;
0128
0129
0130 bool isLeapYear(int year) const;
0131
0132
0133 bool isGregorian() const;
0134 bool isLunar() const;
0135 bool isLuniSolar() const;
0136 bool isSolar() const;
0137 bool isProleptic() const;
0138 bool hasYearZero() const;
0139 int maximumDaysInMonth() const;
0140 int minimumDaysInMonth() const;
0141 int maximumMonthsInYear() const;
0142 QString name() const;
0143
0144
0145 QDate dateFromParts(int year, int month, int day) const;
0146 QDate dateFromParts(const YearMonthDay &parts) const;
0147 QDate matchCenturyToWeekday(const YearMonthDay &parts, int dow) const;
0148 YearMonthDay partsFromDate(QDate date) const;
0149 int dayOfWeek(QDate date) const;
0150
0151
0152 QString monthName(const QLocale &locale, int month, int year = Unspecified,
0153 QLocale::FormatType format=QLocale::LongFormat) const;
0154 QString standaloneMonthName(const QLocale &locale, int month, int year = Unspecified,
0155 QLocale::FormatType format = QLocale::LongFormat) const;
0156 QString weekDayName(const QLocale &locale, int day,
0157 QLocale::FormatType format = QLocale::LongFormat) const;
0158 QString standaloneWeekDayName(const QLocale &locale, int day,
0159 QLocale::FormatType format=QLocale::LongFormat) const;
0160
0161
0162 QString dateTimeToString(QStringView format, const QDateTime &datetime,
0163 QDate dateOnly, QTime timeOnly,
0164 const QLocale &locale) const;
0165
0166
0167 static QStringList availableCalendars();
0168 private:
0169
0170
0171
0172
0173 const QCalendarBackend *d_ptr;
0174 };
0175
0176 QT_END_NAMESPACE
0177
0178 #endif