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 and astronomical season dates (equinoxes
214 * and solstices) that occur between @p startDate and @p endDate.
215 *
216 */
217 Holiday::List rawHolidaysWithAstroSeasons(const QDate &startDate, const QDate &endDate) const;
218
219 /**
220 * @since 5.97
221 *
222 * Returns the list of holidays that occur between @p startDate and @p endDate.
223 */
224 Holiday::List rawHolidays(const QDate &startDate, const QDate &endDate) const;
225
226 /**
227 * @since 5.95
228 *
229 * Returns the list of holidays and astronomical season dates (equinoxes
230 * and solstices) that occur on a @p date.
231 */
232 Holiday::List rawHolidaysWithAstroSeasons(const QDate &date) const;
233
234 /**
235 * @since 5.95
236 *
237 * Returns the list of holidays and astronomical season dates (equinoxes
238 * and solstices) that occur in a Gregorian calendar year @p calendarYear.
239 */
240 Holiday::List rawHolidaysWithAstroSeasons(int calendarYear) const;
241
242 /**
243 * @since 5.95
244 *
245 * Returns the list of holidays that occur between @p startDate and @p endDate and with @p category.
246 */
247 Holiday::List rawHolidays(const QDate &startDate, const QDate &endDate, const QString &category) const;
248
249 /**
250 * Checks whether there is any holiday defined for a @p date.
251 */
252 bool isHoliday(const QDate &date) const;
253
254 /**
255 * Returns whether the instance contains any holiday data.
256 */
257 bool isValid() const;
258
259 /**
260 * @since 4.5
261 *
262 * Returns whether the Region Code is valid.
263 */
264 static bool isValid(const QString &regionCode);
265
266private:
268};
269
270}
271
272#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 Mon Nov 18 2024 12:11:11 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.