KHolidays

holidayregion.h
1/*
2 This file is part of the kholidays library.
3
4 SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
5 SPDX-FileCopyrightText: 2004 Allen Winter <winter@kde.org>
6 SPDX-FileCopyrightText: 2008 David Jarvie <djarvie@kde.org>
7 SPDX-FileCopyrightText: 2010 John Layt <john@layt.net>
8
9 SPDX-License-Identifier: LGPL-2.0-or-later
10*/
11
12#ifndef KHOLIDAYS_HOLIDAYREGION_H
13#define KHOLIDAYS_HOLIDAYREGION_H
14
15#include "kholidays_export.h"
16
17#include <QSharedDataPointer>
18#include <QString>
19#include <QStringList>
20
21#include "holiday.h"
22
23class QDate;
24class QFileInfo;
25
26namespace KHolidays
27{
28class HolidayRegionPrivate;
29
30/** Represents a holiday region. */
31class KHOLIDAYS_EXPORT HolidayRegion
32{
33public:
34 /**
35 * Creates a new Holiday Region object for a given standard Region Code.
36 *
37 * @param regionCode The code for the Holiday Region.
38 * If null or unknown, an empty instance will be created.
39 */
40 explicit HolidayRegion(const QString &regionCode = QString());
41
42 /**
43 * Creates a new Holiday Region object from a given holiday file.
44 * If file doesn't exist, an empty instance will be created.
45 *
46 * @param regionFile The code for the Holiday Region.
47 */
48 explicit HolidayRegion(const QFileInfo &regionFile);
49
50 /** Copy constructor.
51 * @since 5.77
52 */
54 /** Move constructor.
55 * @since 5.77
56 */
58
59 /**
60 * Destroys the holidays object.
61 */
63
64 /** Assignment operator.
65 * @since 5.77
66 */
68 /** Move Assignment operator.
69 * @since 5.77
70 */
72
73 /**
74 * @since 4.5
75 *
76 * Return a list of all available Holiday Region codes.
77 *
78 * One of these can then be passed to the constructor for a new HolidayRegion
79 * object, or to name() or language() to obtain the name and language of the region.
80 *
81 * @see name()
82 * @see languageCode()
83 */
84 static QStringList regionCodes();
85
86 /**
87 * @since 4.6
88 *
89 * Return a reasonable default Holiday Region code
90 *
91 * If a required country/language is not provided then the current KDE
92 * country/language is used.
93 *
94 * @param country The country or region to find a default Holiday Region for.
95 * This can be either an ISO 3166-1 or ISO 3166-2 code.
96 * @param language The language to find a default Holiday Region for
97 * @return the full region code of the default file
98 * @warning This methods is expensive as it involves parsing all holiday definition files.
99 */
100 static QString defaultRegionCode(const QString &country = QString(), const QString &language = QString());
101
102 /**
103 * @since 4.5
104 *
105 * Returns the unique Holiday Region code.
106 *
107 * Clients should not infer any meaning from the format of the code.
108 *
109 * @return region code, or null if the instance was constructed with
110 * an unknown region
111 */
112 QString regionCode() const;
113
114 /**
115 * @since 4.5
116 *
117 * Return the ISO 3166 country code of the file
118 *
119 * May be either just a country code ("US" = USA) or may include a regional
120 * identifier ("US-CA" = California). Returns "XX" if not a country.
121 *
122 * See https://en.wikipedia.org/wiki/ISO_3166-2
123 *
124 * @return the full region code of the file
125 */
126 QString countryCode() const;
127
128 /**
129 * @since 4.5
130 *
131 * Return the ISO 3166 country code of a given Holiday Region
132 *
133 * May be either just a country code ("US" = USA) or may include a regional
134 * identifier ("US-CA" = California). Returns "XX" if not a country.
135 *
136 * See https://en.wikipedia.org/wiki/ISO_3166-2
137 *
138 * @param regionCode The code for the Holiday Region.
139 * @return the full region code of the file
140 * @warning This methods is expensive as it involves parsing the corresponding holiday
141 * definition file. Prefer HolidayRegion::countryCode().
142 */
143 static QString countryCode(const QString &regionCode);
144
145 /**
146 * @since 4.5
147 *
148 * Return the ISO 639-1 language code of the file
149 *
150 * May be either just a language code ("en" = US English) or may include a country
151 * identifier ("en_GB" = British English).
152 *
153 * @return the language code of the file
154 */
155 QString languageCode() const;
156
157 /**
158 * @since 4.5
159 *
160 * Return the ISO 639-1 language code of a given Holiday Region
161 *
162 * May be either just a language code ("en" = US English) or may include a country
163 * identifier ("en_GB" = British English).
164 *
165 * @param regionCode The code for the Holiday Region.
166 * @return the language code of the file
167 * @warning This methods is expensive as it involves parsing the corresponding holiday
168 * definition file. Prefer HolidayRegion::languageCode().
169 */
170 static QString languageCode(const QString &regionCode);
171
172 /**
173 * @since 4.5
174 *
175 * Return the name of the Holiday Region.
176 * This may be a country, region, or type.
177 *
178 * @return the short name code of the file
179 */
180 QString name() const;
181
182 /**
183 * @since 4.5
184 *
185 * Return the name of a given Holiday Region
186 *
187 * @param regionCode The code for the Holiday Region.
188 * @return the name of the Holiday Region
189 */
190 static QString name(const QString &regionCode);
191
192 /**
193 * @since 4.5
194 *
195 * Return the description of the Holiday Region if available
196 *
197 * @return the description of the Holiday Region
198 */
199 QString description() const;
200
201 /**
202 * @since 4.5
203 *
204 * Return the description of a given Holiday Region if available
205 *
206 * @return the description of the Holiday Region
207 */
208 static QString description(const QString &regionCode);
209
210 /**
211 * @since 5.95
212 *
213 * Returns the list of holidays that occur between @p startDate and @p endDate.
214 *
215 */
216 Holiday::List rawHolidaysWithAstroSeasons(const QDate &startDate, const QDate &endDate) const;
217
218 /**
219 * @since 5.97
220 *
221 * Returns the list of holidays that occur between @p startDate and @p endDate.
222 */
223 Holiday::List rawHolidays(const QDate &startDate, const QDate &endDate) const;
224
225 /**
226 * @since 5.95
227 *
228 * Returns the list of holidays that occur on a @p date.
229 */
230 Holiday::List rawHolidaysWithAstroSeasons(const QDate &date) const;
231
232 /**
233 * @since 5.95
234 *
235 * Returns the list of holidays that occur in a Gregorian calendar year @p calendarYear.
236 */
237 Holiday::List rawHolidaysWithAstroSeasons(int calendarYear) const;
238
239 /**
240 * @since 5.95
241 *
242 * Returns the list of holidays that occur between @p startDate and @p endDate and with @p category.
243 */
244 Holiday::List rawHolidays(const QDate &startDate, const QDate &endDate, const QString &category) const;
245
246 /**
247 * Checks whether there is any holiday defined for a @p date.
248 */
249 bool isHoliday(const QDate &date) const;
250
251 /**
252 * Returns whether the instance contains any holiday data.
253 */
254 bool isValid() const;
255
256 /**
257 * @since 4.5
258 *
259 * Returns whether the Region Code is valid.
260 */
261 static bool isValid(const QString &regionCode);
262
263private:
265};
266
267}
268
269#endif // KHOLIDAYS_HOLIDAYREGION_H
Represents a holiday region.
~HolidayRegion()
Destroys the holidays object.
HolidayRegion(const HolidayRegion &)
Copy constructor.
HolidayRegion(HolidayRegion &&)
Move constructor.
HolidayRegion & operator=(HolidayRegion &&)
Move Assignment operator.
HolidayRegion & operator=(const HolidayRegion &)
Assignment operator.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:37 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.