Debian Codegraph @

kysdk-qtwidgets/src/klunarcalendarinfo.h

raw
1 /*
2 * libkysdk-qtwidgets's Library
3 *
4 * Copyright (C) 2024, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Zhenyu Wang <[email protected]>
20 *
21 */
22
23 #ifndef KLUNARCALENDARINFO_H
24 #define KLUNARCALENDARINFO_H
25
26 #include "gui_g.h"
27 #include <QObject>
28
29 namespace kdk
30 {
31 class KLunarCalendarInfoPrivate;
32
33 /**
34 * @defgroup KLunarCalendarInfo
35 * @since 2.5.2.0
36 */
37
38 class GUI_EXPORT KLunarCalendarInfo : public QObject
39 {
40 Q_OBJECT
41 public:
42 static KLunarCalendarInfo *Instance();
43 explicit KLunarCalendarInfo(QObject *parent = 0);
44
45 /**
46 * @brief 计算是否闰年
47 * @param year
48 * @return
49 */
50 bool isLoopYear(int year);
51
52 /**
53 * @brief 计算指定年月该月共多少天
54 * @param year
55 * @param month
56 * @return
57 */
58 int getMonthDays(int year, int month);
59
60 /**
61 * @brief 计算指定年月对应到该月共多少天
62 * @param year
63 * @param month
64 * @return
65 */
66 int getTotalMonthDays(int year, int month);
67
68 /**
69 * @brief 计算指定年月对应星期几
70 * @param year
71 * @param month
72 * @param FirstDayisSun:第一天是否以周日开始
73 * @return
74 */
75 int getFirstDayOfWeek(int year, int month, bool FirstDayisSun);
76
77 /**
78 * @brief 计算国际节日
79 * @param month
80 * @param day
81 * @return
82 */
83 QString getHoliday(int month, int day);
84
85 /**
86 * @brief 计算二十四节气
87 * @param year
88 * @param month
89 * @param day
90 * @return
91 */
92 QString getSolarTerms(int year, int month, int day);
93
94 /**
95 * @brief 计算农历节日(必须传入农历年份月份)
96 * @param month
97 * @param day
98 * @return
99 */
100 QString getLunarFestival(int month, int day);
101
102 /**
103 * @brief 计算农历年 天干+地支+生肖
104 * @param year
105 * @return
106 */
107 QString getLunarYear(int year);
108
109 /**
110 * @brief 计算指定年月日农历信息,包括公历节日和农历节日及二十四节气
111 * @param year
112 * @param month
113 * @param day
114 * @param strHoliday
115 * @param strSolarTerms
116 * @param strLunarFestival
117 * @param strLunarYear
118 * @param strLunarMonth
119 * @param strLunarDay
120 */
121 void getLunarCalendarInfo(int year, int month, int day,
122 QString &strHoliday,
123 QString &strSolarTerms,
124 QString &strLunarFestival,
125 QString &strLunarYear,
126 QString &strLunarMonth,
127 QString &strLunarDay);
128
129 /**
130 * @brief 获取指定年月日农历信息
131 * @param year
132 * @param month
133 * @param day
134 * @param yearInfo
135 * @param monthInfo
136 * @param dayInfo
137 * @return
138 */
139 QString getLunarInfo(int year, int month, int day, bool yearInfo, bool monthInfo, bool dayInfo);
140
141 /**
142 * @brief 获取农历年月日
143 * @param year
144 * @param month
145 * @param day
146 * @return
147 */
148 QString getLunarYearMonthDay(int year, int month, int day);
149
150 /**
151 * @brief 获取农历月日
152 * @param year
153 * @param month
154 * @param day
155 * @return
156 */
157 QString getLunarMonthDay(int year, int month, int day);
158
159 /**
160 * @brief 获取农历日
161 * @param year
162 * @param month
163 * @param day
164 * @return
165 */
166 QString getLunarDay(int year, int month, int day);
167
168 private:
169 Q_DECLARE_PRIVATE(KLunarCalendarInfo)
170 KLunarCalendarInfoPrivate *const d_ptr;
171 static QScopedPointer<KLunarCalendarInfo> self;
172 };
173 }
174
175 #endif // KLUNARCALENDARINFO_H