Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhijricalendar.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 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// Qt-Security score:significant reason:default
4
5#include "qglobal.h"
8
10
11/*!
12 \since 5.14
13 \internal
14
15 \class QHijriCalendar
16 \inmodule QtCore
17 \brief The QHijriCalendar class supports Islamic (Hijri) calendar implementations.
18
19 \section1 Islamic Calendar System
20
21 The Islamic, Muslim, or Hijri calendar is a lunar calendar consisting of 12
22 months in a year of 354 or 355 days. It is used (often alongside the
23 Gregorian calendar) to date events in many Muslim countries. It is also used
24 by Muslims to determine the proper days of Islamic holidays and rituals,
25 such as the annual period of fasting and the proper time for the pilgrimage
26 to Mecca.
27
28 Source: \l {https://en.wikipedia.org/wiki/Islamic_calendar}{Wikipedia page
29 on Hijri Calendar}
30
31 \section1 Support for variants
32
33 This base class provides the common details shared by all variants on the
34 Islamic calendar. Each year comprises 12 months of 29 or 30 days each; most
35 years have as many of 29 as of 30, but leap years extend one 29-day month to
36 30 days. In tabular versions of the calendar (where mathematical rules are
37 used to determine the details), odd-numbered months have 30 days, as does
38 the last (twelfth) month of a leap year; all other months have 29
39 days. Other versions are based on actual astronomical observations of the
40 moon's phase at sunset, which vary from place to place.
41
42 \sa QIslamicCivilCalendar, QCalendar
43*/
44
45bool QHijriCalendar::isLunar() const
46{
47 return true;
48}
49
50bool QHijriCalendar::isLuniSolar() const
51{
52 return false;
53}
54
55bool QHijriCalendar::isSolar() const
56{
57 return false;
58}
59
60int QHijriCalendar::daysInMonth(int month, int year) const
61{
62 if (year == 0 || month < 1 || month > 12)
63 return 0;
64
65 if (month == 12 && (year == QCalendar::Unspecified || isLeapYear(year)))
66 return 30;
67
68 return month % 2 == 0 ? 29 : 30;
69}
70
71int QHijriCalendar::maximumDaysInMonth() const
72{
73 return 30;
74}
75
76int QHijriCalendar::daysInYear(int year) const
77{
78 return monthsInYear(year) ? isLeapYear(year) ? 355 : 354 : 0;
79}
80
81const QCalendarLocale *QHijriCalendar::localeMonthIndexData() const
82{
83 return QtPrivate::Hijri::locale_data;
84}
85
86const char16_t *QHijriCalendar::localeMonthData() const
87{
88 return QtPrivate::Hijri::months_data;
89}
90
91QT_END_NAMESPACE
Combined button and popup list for selecting options.