summaryrefslogtreecommitdiffabout
path: root/microkde/kcalendarsystem.h
Unidiff
Diffstat (limited to 'microkde/kcalendarsystem.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kcalendarsystem.h297
1 files changed, 297 insertions, 0 deletions
diff --git a/microkde/kcalendarsystem.h b/microkde/kcalendarsystem.h
new file mode 100644
index 0000000..37af33e
--- a/dev/null
+++ b/microkde/kcalendarsystem.h
@@ -0,0 +1,297 @@
1/*
2 Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es>
3 Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21#ifndef KCALENDARSYSTEM_H
22#define KCALENDARSYSTEM_H
23
24#include <qdatetime.h>
25#include <qstring.h>
26
27class KLocale;
28
29class KCalendarSystemPrivate;
30
31/**
32 * CalendarSystem abstract class, default derived kde gregorian class and
33 * factory class. Provides support for different calendar types for kde
34 * calendar widget and related stuff.
35 *
36 * Derived classes must be created through KCalendarFactory class
37 *
38 * @author Carlos Moro <cfmoro@correo.uniovi.es>
39 * @licence GNU-GPL v.2
40 * @version $Id$
41 * @since 3.2
42 */
43class KCalendarSystem
44{
45public:
46 /**
47 * Constructor of abstract calendar class. This will be called by the derived classes.
48 *
49 * @param locale It will use this locale for translations, 0 means global.
50 */
51 KCalendarSystem(const KLocale * locale = 0);
52
53 /**
54 * Descructor.
55 */
56 virtual ~KCalendarSystem();
57
58 /**
59 * Gets specific calendar type year for a given gregorian date
60 *
61 * @param date gregorian date
62 * @return year
63 */
64 virtual int year (const QDate & date) const = 0;
65
66 /**
67 * Gets specific calendar type month for a given gregorian date
68 *
69 * @param date gregorian date
70 * @return month number
71 */
72 virtual int month (const QDate & date) const = 0;
73
74 /**
75 * Gets specific calendar type day number of month for a given date
76 *
77 * @param date gregorian date equivalent to the specific one
78 * @return day of the month
79 */
80 virtual int day (const QDate & date) const = 0;
81
82 /**
83 * Gets specific calendar type number of day of week number for a given
84 * date
85 *
86 * @param date gregorian date
87 * @return day of week
88 */
89 virtual int dayOfWeek (const QDate & date) const = 0;
90
91 /**
92 * Gets specific calendar type day number of year for a given date
93 *
94 * @param date gregorian date equivalent to the specific one
95 * @return day number
96 */
97 virtual int dayOfYear (const QDate & date) const = 0;
98
99 /**
100 * Changes the date's year, month and day. The range of the year, month
101 * and day depends on which calendar is being used.
102 *
103 * @param date Date to change
104 * @param y Year
105 * @param m Month number
106 * @param d Day of month
107 * @return TRUE if the date is valid; otherwise returns FALSE.
108 */
109 virtual bool setYMD(QDate & date, int y, int m, int d) const = 0;
110
111 /**
112 * Returns a QDate object containing a date nyears later.
113 *
114 * @param date The old date
115 * @param nyears The number of years to add
116 * @return The new date
117 */
118 virtual QDate addYears(const QDate & date, int nyears) const = 0;
119
120 /**
121 * Returns a QDate object containing a date nmonths later.
122 *
123 * @param date The old date
124 * @param nmonths The number of months to add
125 * @return The new date
126 */
127 virtual QDate addMonths(const QDate & date, int nmonths) const = 0;
128
129 /**
130 * Returns a QDate object containing a date ndays later.
131 *
132 * @param date The old date
133 * @param ndays The number of days to add
134 * @return The new date
135 */
136 virtual QDate addDays(const QDate & date, int ndays) const = 0;
137
138 /**
139 * Gets specific calendar type number of month for a given year
140 *
141 * @param date The date whose year to use
142 * @return The number of months in that year
143 */
144 virtual int monthsInYear (const QDate & date) const = 0;
145
146 /**
147 * Gets the number of days in date whose years specified.
148 *
149 * @param date Gregorian date equivalent to the specific one
150 * @return The number of days in year
151 */
152 virtual int daysInYear (const QDate & date) const = 0;
153
154 /**
155 * Gets specific calendar type number of days in month for a given date
156 *
157 * @param date gregorian date
158 * @return number of days for month in date
159 */
160 virtual int daysInMonth (const QDate & date) const = 0;
161
162 /**
163 * Gets the number of weeks in year
164 *
165 * @param year the year
166 * @return number of weeks in year
167 */
168 virtual int weeksInYear(int year) const = 0;
169
170 /**
171 * Gets specific calendar type week number for a given date
172 *
173 * @param date gregorian date
174 * @return week number
175 */
176 virtual int weekNumber(const QDate& date, int * yearNum = 0) const = 0;
177
178 /**
179 * Gets specific calendar type month name for a given month number
180 * If an invalid month is specified, QString::null is returned.
181 *
182 * @param month The month number
183 * @param shortName Specifies if the short month name should be used
184 * @return The name of the month
185 */
186 virtual QString monthName (int month, bool shortName = false) const = 0;
187
188 /**
189 * Gets specific calendar type month name for a given gregorian date
190 *
191 * @param date Gregorian date
192 * @param shortName Specifies if the short month name should be used
193 * @return The name of the month
194 */
195 virtual QString monthName (const QDate & date, bool shortName = false ) const = 0;
196
197 /**
198 * Returns a string containing the possessive form of the month name.
199 * ("of January", "of February", etc.)
200 * It's needed in long format dates in some languages.
201 * If an invalid month is specified, QString::null is returned.
202 *
203 * @param month The month number
204 * @param shortName Specifies if the short month name should be used
205 *
206 * @return The possessive form of the name of the month
207 */
208 virtual QString monthNamePossessive(int month, bool shortName = false) const = 0;
209
210 /**
211 * Returns a string containing the possessive form of the month name.
212 * ("of January", "of February", etc.)
213 * It's needed in long format dates in some languages.
214 *
215 * @param date Gregorian date
216 * @param shortName Specifies if the short month name should be used
217 *
218 * @return The possessive form of the name of the month
219 */
220 virtual QString monthNamePossessive(const QDate & date, bool shortName = false) const = 0;
221
222 /**
223 * Gets specific calendar type week day name
224 * If an invalid week day is specified, QString::null is returned.
225 *
226 * @param weekDay number of day in week (1 -> Monday)
227 * @param shortName short or complete day name
228 * @return day name
229 */
230 virtual QString weekDayName (int weekDay, bool shortName = false) const = 0;
231
232 /**
233 * Gets specific calendar type week day name
234 *
235 * @param date the date
236 * @param shortName short or complete day name
237 * @return day name
238 */
239 virtual QString weekDayName (const QDate & date, bool shortName = false) const = 0;
240
241 /**
242 * Gets the first year value supported by specific calendar type
243 * algorithms.
244 *
245 * @return first year supported
246 */
247 virtual int minValidYear () const = 0;
248
249 /**
250 * Gets the maximum year value supported by specific calendar type
251 * algorithms (QDate, 8000)
252 *
253 * @return maximum year supported
254 */
255 virtual int maxValidYear () const = 0;
256
257 /**
258 * Gets the day of the week traditionaly associated with pray
259 *
260 * @return day number
261 */
262 virtual int weekDayOfPray () const = 0;
263
264 /**
265 * Gets the string representing the calendar
266 */
267 virtual QString calendarName() const = 0;
268
269 /**
270 * Gets if the calendar is lunar based
271 *
272 * @return if the calendar is lunar based
273 */
274 virtual bool isLunar() const = 0;
275
276 /**
277 * Gets if the calendar is lunisolar based
278 *
279 * @return if the calendar is lunisolar based
280 */
281 virtual bool isLunisolar() const = 0;
282
283 /**
284 * Gets if the calendar is solar based
285 *
286 * @return if the calendar is solar based
287 */
288 virtual bool isSolar() const = 0;
289
290protected:
291 const KLocale * locale() const;
292
293private:
294 KCalendarSystemPrivate * d;
295};
296
297#endif