File indexing completed on 2025-01-19 04:46:47
0001 /* 0002 This file is part of the kholidays library. 0003 0004 SPDX-FileCopyrightText: 2014 John Layt <john@layt.net> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <QDate> 0012 #include <QSharedPointer> 0013 0014 class QCalendarSystemPrivate; 0015 0016 class QCalendarSystem 0017 { 0018 public: 0019 enum CalendarSystem { 0020 DefaultCalendar = 0, 0021 GregorianCalendar = 1, 0022 ChineseCalendar = 2, 0023 CopticCalendar = 3, 0024 EthiopicCalendar = 4, 0025 EthiopicAmeteAlemCalendar = 5, 0026 HebrewCalendar = 6, 0027 IndianNationalCalendar = 7, 0028 IslamicCalendar = 8, 0029 IslamicCivilCalendar = 9, 0030 ISO8601Calendar = 10, 0031 JapaneseCalendar = 11, 0032 JulianCalendar = 12, 0033 PersianCalendar = 13, 0034 ROCCalendar = 14, 0035 ThaiCalendar = 15, 0036 LastCalendar = ThaiCalendar, 0037 }; 0038 0039 explicit QCalendarSystem(QCalendarSystem::CalendarSystem calendar = QCalendarSystem::DefaultCalendar); 0040 ~QCalendarSystem(); 0041 0042 QCalendarSystem &operator=(const QCalendarSystem &other); 0043 0044 QCalendarSystem::CalendarSystem calendarSystem() const; 0045 0046 QDate epoch() const; 0047 QDate earliestValidDate() const; 0048 QDate latestValidDate() const; 0049 int maximumMonthsInYear() const; 0050 int maximumDaysInYear() const; 0051 int maximumDaysInMonth() const; 0052 0053 bool isValid(const QDate &date) const; 0054 bool isValid(int year, int month, int day) const; 0055 bool isValid(int year, int dayOfYear) const; 0056 0057 QDate date(int year, int month, int day) const; 0058 QDate date(int year, int dayOfYear) const; 0059 0060 void getDate(const QDate &date, int *year, int *month, int *day) const; 0061 0062 int year(const QDate &date) const; 0063 int month(const QDate &date) const; 0064 int day(const QDate &date) const; 0065 0066 int quarter(const QDate &date) const; 0067 int quarter(int year, int month, int day) const; 0068 0069 int dayOfYear(const QDate &date) const; 0070 int dayOfYear(int year, int month, int day) const; 0071 0072 int dayOfWeek(const QDate &date) const; 0073 int dayOfWeek(int year, int month, int day) const; 0074 0075 int weekNumber(const QDate &date, int *yearNum = nullptr) const; 0076 int weekNumber(int year, int month, int day, int *yearNum = nullptr) const; 0077 0078 int monthsInYear(const QDate &date) const; 0079 int monthsInYear(int year) const; 0080 0081 int weeksInYear(const QDate &date) const; 0082 int weeksInYear(int year) const; 0083 0084 int daysInYear(const QDate &date) const; 0085 int daysInYear(int year) const; 0086 0087 int daysInMonth(const QDate &date) const; 0088 int daysInMonth(int year, int month) const; 0089 0090 int daysInWeek() const; 0091 0092 bool isLeapYear(const QDate &date) const; 0093 bool isLeapYear(int year) const; 0094 0095 QDate addYears(const QDate &date, int years) const; 0096 QDate addMonths(const QDate &date, int months) const; 0097 QDate addDays(const QDate &date, int days) const; 0098 0099 int yearsDifference(const QDate &fromDate, const QDate &toDate) const; 0100 int monthsDifference(const QDate &fromDate, const QDate &toDate) const; 0101 qint64 daysDifference(const QDate &fromDate, const QDate &toDate) const; 0102 0103 void dateDifference(const QDate &fromDate, const QDate &toDate, int *years, int *months, int *days, int *direction) const; 0104 0105 QDate firstDayOfYear(const QDate &date) const; 0106 QDate firstDayOfYear(int year) const; 0107 QDate lastDayOfYear(const QDate &date) const; 0108 QDate lastDayOfYear(int year) const; 0109 0110 QDate firstDayOfMonth(const QDate &date) const; 0111 QDate firstDayOfMonth(int year, int month) const; 0112 QDate lastDayOfMonth(const QDate &date) const; 0113 QDate lastDayOfMonth(int year, int month) const; 0114 0115 private: 0116 QSharedDataPointer<QCalendarSystemPrivate> d; 0117 };