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