~ubuntu-branches/ubuntu/natty/kde4libs/natty-proposed

« back to all changes in this revision

Viewing changes to kdecore/date/klocalizeddate.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell, Scott Kitterman, Jonathan Riddell
  • Date: 2010-11-22 17:59:02 UTC
  • mfrom: (1.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122175902-yubxubd0pg6hn11z
Tags: 4:4.5.80a-0ubuntu1
[ Scott Kitterman ]
* New upstream beta release
  - Refreshed all patches
  - Updated debian/patches/10_make_libkdeinit4_private.diff to use Qfile
    instead of Qstring in kdecore/kernel/kstandarddirs_unix.cpp
  - Updated debian/patches/kubuntu_01_kubuntu_useragent.diff to provide
    Kubuntu in the Konqueror user agen string with the changes in
    kio/kio/kprotocolmanager.cpp
  - Partially updated debian/patches/kubuntu_05_langpack_desktop_files.diff
    and left the balance in kdecore/localization/klocale.cpp.rej for later
    revision
  - Update debian/patches/kubuntu_06_user_disk_mounting.diff for changes in
    solid/solid/backends/hal/halstorageaccess.cpp
  - Remove debian/patches/kubuntu_71_backport_plasma_webview_changes.diff
    (backported from upstream, so already present now)
  - Add minimum version for libattica-dev of 0.1.90 to build-depends
  - Bump minimum version for libsoprano-dev build-depend to 2.5.60
  - Add minimum version for shared-desktop-ontologies of 0.5 in build-dep

[ Jonathan Riddell ]
* Add build-depends on grantlee, libudev-dev, hupnp (FIXME needs packaging fixes)
* Update kubuntu_04_add_langpack_path.diff 28_find_old_kde4_html_documentation.diff
  22_hack_in_etc_kde4_in_kstandarddirs.diff for QT_NO_CAST_FROM_ASCII
* Update kubuntu_05_langpack_desktop_files.diff for new upstream code
* Add kubuntu_78_solid_trunk.diff to fix solid linking
* Add libnepomukutils4 package for new library
* Don't install kcm_ssl for now, e-mailed upstream to suggest moving to kdebase
* Add kubuntu_79_knewstuff_fix.diff to fix compile broken by non-trunk commit
  http://websvn.kde.org/?view=revision&revision=1199825
* kdelibs5-data replaces old kdebase-runtime-data due to moved file
* Add kubuntu_80_find_hupnp.diff to find hupnp include files, committed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2010 John Layt <john@layt.net>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2 of the License, or (at your option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
    Library General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to
 
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef KDATE_H
 
21
#define KDATE_H
 
22
 
 
23
#include <QtCore/QString>
 
24
#include <QtCore/QDate>
 
25
 
 
26
#include <kdecore_export.h>
 
27
#include "kcalendarsystem.h"
 
28
#include "klocale.h"
 
29
 
 
30
class KLocalizedDatePrivate;
 
31
/**
 
32
 * @short A class representing a date localized using the local calendar system, language and formats
 
33
 *
 
34
 * Topics:
 
35
 *  - @ref intro
 
36
 *  - @ref calsys
 
37
 *  - @ref custom
 
38
 *  - @ref formatting
 
39
 *  - @ref maths
 
40
 *
 
41
 * @section intro Introduction
 
42
 *
 
43
 * This class provides a simple and convenient way to localize dates
 
44
 *
 
45
 * @section calsys Calendar System
 
46
 *
 
47
 * KDE supports the use of different calendar systems.
 
48
 *
 
49
 * @section custom Default and Custom Locale and Calendar System
 
50
 *
 
51
 * In most cases you will want to use the default Global Locale and Calendar
 
52
 * System, in which case you need only create a default KLocalizedDate.  If
 
53
 * however you specifically need a different Calendar System or Locale settings
 
54
 * then you need to take some extra steps.
 
55
 *
 
56
 * The simplest method is just changing the Calendar System while keeping the
 
57
 * current Locale settings.  This is easily done using setCalendarSystem()
 
58
 * which will copy the current Locale being used and apply this to the new
 
59
 * Calendar System.  Note this means any changes to the old locale settings,
 
60
 * either the Global Locale or a custom Locale (see below) will not apply
 
61
 * to that date instance.
 
62
 *
 
63
 * You may however wish to use a custom Locale with the Calendar System.
 
64
 * For example, if you want your app to normally show dates using the Global
 
65
 * Locale and Calendar System, but wish to show an info box with the Islamic
 
66
 * date in Arabic language and format, then you need a custom Locale to do
 
67
 * this.
 
68
 *
 
69
 * \code
 
70
 * KLocale *myLocale = new KLocale("myapp", "ar", "eg");
 
71
 * KCalendarSystem *myCalendar = KCalendarSystem::create(KLocale::IslamicCivilCalendar, myLocale);
 
72
 * KLocalizedDate myDate(QDate(2010,1,1), myCalendar);
 
73
 * \endcode
 
74
 *
 
75
 * In this case you are responsible for the memory management of the KLocale
 
76
 * and KCalendarSystem.  This allows you to reuse this calendar across multiple
 
77
 * date instances without it being deleted under you.  It also allows you to
 
78
 * change any setting in the Locale and have it apply acrooss all those date
 
79
 * instances.  @warning Don't try changing the Calendar System via your Locale
 
80
 * instance, your KCalendarSystem instance will be deleted and all the dates
 
81
 * will be invalid!
 
82
 *
 
83
 * @see 
 
84
 *
 
85
 * @section formatting Date Formatting
 
86
 *
 
87
 * When you display dates or date components to users in a GUI, they will
 
88
 * expect them to be displayed in their language and digit set following their
 
89
 * local date formatting conventions.  Directly displaying values returned by
 
90
 * the normal date component methods such as day() will not conform to these
 
91
 * expectations, so you need to use different methods to obtain the localized
 
92
 * string form of the date or component.
 
93
 *
 
94
 * You can either format the entire date, or just a single component of the
 
95
 * date such as the month or day.
 
96
 *
 
97
 * When formatting a full date, it is preferred to use one of the standard date
 
98
 * formats defined in the Locale, although you can provide your own format in
 
99
 * either the KDE, POSIX, or UNICODE standards.
 
100
 *
 
101
 * @see formatDate() formatDateComponent() formatWeek() formatDayOfWeek()
 
102
 *
 
103
 * @section parsing Date Parsing
 
104
 *
 
105
 * Basic concepts on date parsing, then full details on KLocale::ReadDateFlags
 
106
 * formats, definging your own date format strings, and setting how strictly
 
107
 * the format is appplied.
 
108
 *
 
109
 * You can choose how strictly a date format is applied in parsing.  Currently
 
110
 * only liberal Parsing is supported.
 
111
 *
 
112
 * The KLocale::LiberalParsing mode applies the following rules:
 
113
 * 
 
114
 * 1) You must supply a format and string containing at least one of the following combinations to
 
115
 * create a valid date:
 
116
 * @li a month and day of month
 
117
 * @li a day of year
 
118
 * @li a ISO week number and day of week
 
119
 *
 
120
 * 2) If a year number is not supplied then the current year will be assumed.
 
121
 *
 
122
 * 3) All date componants must be separated by a non-numeric character.
 
123
 *
 
124
 * 4) The format is not applied strictly to the input string:
 
125
 * @li extra whitespace is ignored
 
126
 * @li leading 0's on numbers are ignored
 
127
 * @li capitalisation of literals is ignored
 
128
 *
 
129
 * @see readDate()
 
130
 *
 
131
 * @section maths Date Maths
 
132
 *
 
133
 * A full set of date maths functions are provided which operate in a consistent
 
134
 * manner, i.e. you can safely round-trip.
 
135
 *
 
136
 */
 
137
 
 
138
class KDECORE_EXPORT KLocalizedDate
 
139
{
 
140
public:
 
141
 
 
142
    /**
 
143
     * Constructs a localized date with the given date.
 
144
     *
 
145
     * By default, uses the global Calendar System and Locale.
 
146
     *
 
147
     * If you pass in a custom Calendar System then you retain ownership of it
 
148
     * and are responsible for deleting it.  This allows you to reuse the same
 
149
     * custom Calendar System for many localized date instances.
 
150
     *
 
151
     * See @ref custom for more details on using custom Calendar Systems.
 
152
     *
 
153
     * @param date the QDate to set the KLocalizedDate to, defaults to invalid date
 
154
     * @param locale the locale to use for date formats, defaults to the global
 
155
     */
 
156
    explicit KLocalizedDate(const QDate &date = QDate(), const KCalendarSystem *calendar = 0);
 
157
 
 
158
    /**
 
159
     * Constructs a localized date with the given year, month and day.
 
160
     *
 
161
     * By default, uses the global Calendar System and Locale.
 
162
     *
 
163
     * If you pass in a custom Calendar System then you retain ownership of it
 
164
     * and are responsible for deleting it.  This allows you to reuse the same
 
165
     * custom Calendar System for many localized date instances.
 
166
     *
 
167
     * See @ref custom for more details on using custom Calendar Systems.
 
168
     *
 
169
     * @param year the year to set the KLocalizedDate to
 
170
     * @param month the month to set the KLocalizedDate to
 
171
     * @param day the day to set the KLocalizedDate to
 
172
     */
 
173
    KLocalizedDate(int year, int month, int day, const KCalendarSystem *calendar = 0);
 
174
 
 
175
    /**
 
176
     * Copy constructor
 
177
     *
 
178
     * @param rhs the date to copy
 
179
     */
 
180
    KLocalizedDate(const KLocalizedDate &rhs);
 
181
 
 
182
    /**
 
183
     * Assignment operator
 
184
     *
 
185
     * @param rhs the date to assign
 
186
     */
 
187
    KLocalizedDate &operator=(const KLocalizedDate &rhs);
 
188
 
 
189
    /**
 
190
     * Assignment operator
 
191
     *
 
192
     * @param rhs the date to assign
 
193
     */
 
194
    KLocalizedDate &operator=(const QDate &rhs);
 
195
 
 
196
    /**
 
197
     * Destructor.
 
198
     */
 
199
    ~KLocalizedDate();
 
200
 
 
201
    /**
 
202
     * Set the Calendar System used for this date instance only.
 
203
     *
 
204
     * This method is mostly useful for when you quickly want to see what the
 
205
     * currently set date would look like in a different Calendar System but
 
206
     * using the same Locale.
 
207
     *
 
208
     * When the Calendar System is changed, a copy will be taken of the Locale
 
209
     * previously used and this copy will be applied to the new Calendar System.
 
210
     * Any changes to the old Locale settings, either the Global or a Custom
 
211
     * Locale, will not be applied to this date instance.
 
212
     *
 
213
     * See @ref custom for more details on using custom Calendar Systems.
 
214
     *
 
215
     * @see KLocale::CalendarSystem
 
216
     * @see calendarSystem()
 
217
     * @param calendarSystem the Calendar System to use
 
218
     */
 
219
    void setCalendarSystem(KLocale::CalendarSystem calendarSystem);
 
220
 
 
221
    /**
 
222
     * Returns the Calendar System used by this localized date instance
 
223
     *
 
224
     * @see KLocale::CalendarSystem
 
225
     * @see setCalendarSystem()
 
226
     * @return the Calendar System currently used
 
227
     */
 
228
    KLocale::CalendarSystem calendarSystem();
 
229
 
 
230
    /**
 
231
     * Returns a pointer to the Calendar System object used by this date instance.
 
232
     *
 
233
     * Usually this will be the Global Calendar System, but this may have been
 
234
     * changed.
 
235
     *
 
236
     * Normally you will not need to access this object unless the KLocalizedDate
 
237
     * API does not provide the methods you require.
 
238
     *
 
239
     * @see KCalendarSystem
 
240
     * @see calendarSystem
 
241
     * @see setCalendarSystem
 
242
     * @return the current calendar system instance
 
243
     */
 
244
    const KCalendarSystem *calendar() const;
 
245
 
 
246
    /**
 
247
     * Returns whether the date is null, i.e. invalid in any Calendar System.
 
248
     *
 
249
     * @see isValid
 
250
     * @return @c true if the date is null, @c false otherwise
 
251
     */
 
252
    bool isNull() const;
 
253
 
 
254
    /**
 
255
     * Returns whether the date is valid in the current Calendar System.
 
256
     *
 
257
     * @see isNull
 
258
     * @return @c true if the date is valid, @c false otherwise
 
259
     */
 
260
    bool isValid() const;
 
261
 
 
262
    /**
 
263
     * Set the date using a QDate.
 
264
     *
 
265
     * @param date the QDate to set to
 
266
     * @return @c true if the date is valid, @c false otherwise
 
267
     */
 
268
    bool setDate(const QDate &date);
 
269
 
 
270
    /**
 
271
     * Set the date's year, month and day.
 
272
     *
 
273
     * The range of the year, month and day, and the validity of the date as a
 
274
     * whole depends on which Calendar System is being used.
 
275
     *
 
276
     * @see getDate()
 
277
     * @param year year number
 
278
     * @param month month of year number
 
279
     * @param day day of month
 
280
     * @return @c true if the date is valid, @c false otherwise
 
281
     */
 
282
    bool setDate(int year, int month, int day);
 
283
 
 
284
    /**
 
285
     * Set the date using the year number and day of year number only.
 
286
     *
 
287
     * @see dayOfYear()
 
288
     * @param year year
 
289
     * @param dayOfYear day of year
 
290
     * @return @c true if the date is valid, @c false otherwise
 
291
     */
 
292
    bool setDate(int year, int dayOfYear);
 
293
 
 
294
    /**
 
295
     * Set the date using the era, year in era number, month and day
 
296
     *
 
297
     * @see eraName()
 
298
     * @see yearInEra()
 
299
     * @param eraName Era string
 
300
     * @param year Year In Era number
 
301
     * @param month Month number
 
302
     * @param day Day Of Month number
 
303
     * @return @c true if the date is valid, @c false otherwise
 
304
     */
 
305
    bool setDate(QString eraName, int yearInEra, int month, int day);
 
306
 
 
307
    /**
 
308
     * Set the date using the year, week and day of week.
 
309
     *
 
310
     * Currently only the ISO Week Number System is supported.
 
311
     *
 
312
     * @see week()
 
313
     * @see dayOfWeek()
 
314
     * @param weekNumberSystem the week number system to use
 
315
     * @param year year
 
316
     * @param weekOfYear week of year
 
317
     * @param dayOfWeek day of week Mon..Sun (1..7)
 
318
     * @return @c true if the date is valid, @c false otherwise
 
319
     */
 
320
    bool setDate(KLocale::WeekNumberSystem weekNumberSystem, int year, int weekOfYear, int dayOfWeek);
 
321
 
 
322
    /**
 
323
     * Set the date to today's date
 
324
     *
 
325
     * @see currentDate()
 
326
     * @return @c true if the date is valid, @c false otherwise
 
327
     */
 
328
    bool setCurrentDate();
 
329
 
 
330
    /**
 
331
     * Returns a KLocalizedDate set to today's date in the Global Locale and
 
332
     * Calendar System.
 
333
     *
 
334
     * @see setCurrentDate()
 
335
     * @return today's localized date
 
336
     */
 
337
    static KLocalizedDate currentDate();
 
338
 
 
339
    /**
 
340
     * Returns a KLocalizedDate set the required date in the Global Locale and
 
341
     * Calendar System.
 
342
     *
 
343
     * @param date the date to set to
 
344
     * @return a localized date
 
345
     */
 
346
    static KLocalizedDate fromDate(const QDate &date);
 
347
 
 
348
    /**
 
349
     * Returns a KLocalizedDate set the required Julian Day number in the Global
 
350
     * Locale and Calendar System.
 
351
     *
 
352
     * @see toJulianDay()
 
353
     * @param jd the Julian Day number to set to
 
354
     * @return a localized date
 
355
     */
 
356
    static KLocalizedDate fromJulianDay(int jd);
 
357
 
 
358
    /**
 
359
     * Returns the currently set date as a Julian Day number
 
360
     *
 
361
     * @see fromJulianDay()
 
362
     * @return the currently set date as a Julian Day number
 
363
     */
 
364
    int toJulianDay() const;
 
365
 
 
366
    /**
 
367
     * Returns the currently set date as a QDate
 
368
     *
 
369
     * @return the currently set date as a QDate
 
370
     */
 
371
    QDate date() const;
 
372
 
 
373
    /**
 
374
     * Returns the year, month and day portion of the date in the current
 
375
     * Calendar System.
 
376
     *
 
377
     * See @ref formatting for why you should never display this value.
 
378
     *
 
379
     * @see setDate()
 
380
     * @see formatDate()
 
381
     * @param year year number returned in this variable
 
382
     * @param month month number returned in this variable
 
383
     * @param day day of month returned in this variable
 
384
     */
 
385
    void getDate(int *year, int *month, int *day) const;
 
386
 
 
387
    /**
 
388
     * Returns the year portion of the date in the current calendar system
 
389
     *
 
390
     * See @ref formatting for why you should never display this value.
 
391
     *
 
392
     * @see formatDateComponent()
 
393
     * @return the localized year number
 
394
     */
 
395
    int year() const;
 
396
 
 
397
    /**
 
398
     * Returns the month portion of the date in the current calendar system
 
399
     *
 
400
     * See @ref formatting for why you should never display this value.
 
401
     *
 
402
     * @see formatDateComponent()
 
403
     * @return the localized month number, 0 if date is invalid
 
404
     */
 
405
    int month() const;
 
406
 
 
407
    /**
 
408
     * Returns the day portion of the date in the current calendar system
 
409
     *
 
410
     * See @ref formatting for why you should never display this value.
 
411
     *
 
412
     * @see formatDateComponent()
 
413
     * @return the localized day number, 0 if date is invalid
 
414
     */
 
415
    int day() const;
 
416
 
 
417
    /**
 
418
     * Returns the Era Name portion of the date in the current calendar system,
 
419
     * for example "AD" or "Anno Domini" for the Gregorian calendar and Christian Era.
 
420
     *
 
421
     * See @ref formatting for more details on Date Formatting.
 
422
     *
 
423
     * @see formatDateComponent()
 
424
     * @param format format to return, either short or long
 
425
     * @return the localized era name, empty string if date is invalid
 
426
     */
 
427
    QString eraName() const;
 
428
 
 
429
    /**
 
430
     * Returns the Era Year portion of the date in the current
 
431
     * calendar system, for example "2000 AD" or "Heisei 22".
 
432
     *
 
433
     * See @ref formatting for more details on Date Formatting.
 
434
     *
 
435
     * @see formatDateComponent()
 
436
     * @param format format to return, either short or long
 
437
     * @return the localized era year string, empty string if date is invalid
 
438
     */
 
439
    QString eraYear() const;
 
440
 
 
441
    /**
 
442
     * Returns the Year In Era portion of the date in the current calendar
 
443
     * system, for example 1 for "1 BC".
 
444
     *
 
445
     * See @ref formatting for why you should never display this value.
 
446
     *
 
447
     * @see formatDateComponent()
 
448
     * @see formatYearInEra()
 
449
     * @return the localized Year In Era number, -1 if date is invalid
 
450
     */
 
451
    int yearInEra() const;
 
452
 
 
453
    /**
 
454
     * Returns the day number of year for the date
 
455
     *
 
456
     * See @ref formatting for why you should never display this value.
 
457
     *
 
458
     * @see formatDateComponent()
 
459
     * @return day of year number, -1 if date not valid
 
460
     */
 
461
    int dayOfYear() const;
 
462
 
 
463
    /**
 
464
     * Returns the weekday number for the date
 
465
     *
 
466
     * See @ref formatting for why you should never display this value.
 
467
     *
 
468
     * @see formatDateComponent()
 
469
     * @return day of week number, -1 if date not valid
 
470
     */
 
471
    int dayOfWeek() const;
 
472
 
 
473
    /**
 
474
     * Returns the localized Week Number for the date.
 
475
     *
 
476
     * See @ref formatting for why you should never display this value.
 
477
     *
 
478
     * Currently only the ISO Week Number is supported, but in future the US
 
479
     * and other week number systems will be added.
 
480
     *
 
481
     * If you specifically require the ISO Week, you should use
 
482
     * week(KLocale::IsoWeekNumber)
 
483
     *
 
484
     * ISO 8601 defines the first week of the year as the week containing the first Thursday.
 
485
     * See http://en.wikipedia.org/wiki/ISO_8601 and http://en.wikipedia.org/wiki/ISO_week_date
 
486
     *
 
487
     * If the date falls in the last week of the previous year or the first
 
488
     * week of the following year, then the yearNum returned will be set to the
 
489
     * appropriate year.
 
490
     *
 
491
     * @see weeksInYear()
 
492
     * @see formatDateComponent()
 
493
     * @param yearNum returns the year the date belongs to
 
494
     * @return localized week number, -1 if input date invalid
 
495
     */
 
496
    int week(int *yearNum = 0) const;
 
497
 
 
498
    /**
 
499
     * Returns the Week Number for the date in the required Week Number System.
 
500
     *
 
501
     * See @ref formatting for why you should never display this value.
 
502
     *
 
503
     * Unless you want a specific Week Number System (e.g. ISO Week), you should
 
504
     * use the localized Week Number form of week().
 
505
     *
 
506
     * If the date falls in the last week of the previous year or the first
 
507
     * week of the following year, then the yearNum returned will be set to the
 
508
     * appropriate year.
 
509
     *
 
510
     * Technically, the ISO Week Number only applies to the ISO/Gregorian Calendar
 
511
     * System, but the same rules will be applied to the current Calendar System.
 
512
     *
 
513
     * @see weeksInYear()
 
514
     * @see formatDateComponent()
 
515
     * @param weekNumberSystem the Week Number System to use
 
516
     * @param yearNum returns the year the date belongs to
 
517
     * @return week number, -1 if input date invalid
 
518
     */
 
519
    int week(KLocale::WeekNumberSystem weekNumberSystem, int *yearNum = 0) const;
 
520
 
 
521
    /**
 
522
     * Returns number of months in the year
 
523
     *
 
524
     * See @ref formatting for why you should never display this value.
 
525
     *
 
526
     * @see formatDateComponent()
 
527
     * @return number of months in the year, -1 if  date invalid
 
528
     */
 
529
    int monthsInYear() const;
 
530
 
 
531
    /**
 
532
     * Returns the number of localized weeks in the currently set year.
 
533
     *
 
534
     * See @ref formatting for why you should never display this value.
 
535
     *
 
536
     * Currently only the ISO Week Number is supported, but in future the US
 
537
     * and other week number systems will be added.
 
538
     *
 
539
     * If you specifically require the number of ISO Weeks, you should use
 
540
     * weeksInYear(KLocale::IsoWeekNumber)
 
541
     *
 
542
     * @see week()
 
543
     * @see formatDateComponent()
 
544
     * @return number of weeks in the year, -1 if  date invalid
 
545
     */
 
546
    int weeksInYear() const;
 
547
 
 
548
    /**
 
549
     * Returns the number of Weeks in the currently set year using the required
 
550
     * Week Number System.
 
551
     *
 
552
     * See @ref formatting for why you should never display this value.
 
553
     *
 
554
     * Unless you specifically want a particular Week Number System (e.g. ISO Weeks)
 
555
     * you should use the localized number of weeks provided by weeksInYear().
 
556
     *
 
557
     * @see week()
 
558
     * @see formatDateComponent()
 
559
     * @param weekNumberSystem the week number system to use
 
560
     * @return number of weeks in the year, -1 if  date invalid
 
561
     */
 
562
    int weeksInYear(KLocale::WeekNumberSystem weekNumberSystem) const;
 
563
 
 
564
    /**
 
565
     * Returns the number of days in the year.
 
566
     *
 
567
     * For example, in the Gregorian calendar most years have 365 days but Leap
 
568
     * Years have 366 years.  Other Calendar Systems have different length years.
 
569
     *
 
570
     * See @ref formatting for why you should never display this value.
 
571
     *
 
572
     * @see formatDateComponent()
 
573
     * @return number of days in year, -1 if date invalid
 
574
     */
 
575
    int daysInYear() const;
 
576
 
 
577
    /**
 
578
     * Returns the number of days in the month.
 
579
     *
 
580
     * See @ref formatting for why you should never display this value.
 
581
     *
 
582
     * @see formatDateComponent()
 
583
     * @return number of days in month, -1 if date invalid
 
584
     */
 
585
    int daysInMonth() const;
 
586
 
 
587
    /**
 
588
     * Returns the number of days in the week.
 
589
     *
 
590
     * See @ref formatting for why you should never display this value.
 
591
     *
 
592
     * @see formatDateComponent()
 
593
     * @return number of days in week, -1 if date invalid
 
594
     */
 
595
    int daysInWeek() const;
 
596
 
 
597
    /**
 
598
     * Returns whether the currently set date falls in a Leap Year in the
 
599
     * current Calendar System.
 
600
     *
 
601
     * @return true if the date falls in a leap year
 
602
     */
 
603
    bool isLeapYear() const;
 
604
 
 
605
    /**
 
606
     * Returns the Date as a localized string in the requested standard Locale
 
607
     * format.
 
608
     *
 
609
     * See @ref formatting for more details on Date Formatting and valid Locale
 
610
     * formats.
 
611
     *
 
612
     * @see formatDateComponent()
 
613
     * @param dateFormat the standard date format to use
 
614
     * @return The date as a localized string
 
615
     */
 
616
    QString formatDate(KLocale::DateFormat dateFormat = KLocale::LongDate) const;
 
617
 
 
618
    /**
 
619
     * Returns the Date as a localized string in the requested format.
 
620
     *
 
621
     * See @ref formatting for more details on Date Formatting and valid format
 
622
     * codes.
 
623
     *
 
624
     * Please use with care and only in situations where the standard Locale
 
625
     * formats or the componant format methods do not provide what you
 
626
     * need.  You should almost always translate your @p formatString as
 
627
     * documented above.  Using the standard DateFormat options instead would
 
628
     * take care of the translation for you.
 
629
     *
 
630
     * The toFormat parameter is a good candidate to be made translatable,
 
631
     * so that translators can adapt it to their language's convention.
 
632
     * There should also be a context using the "kdedt-format" keyword (for
 
633
     * automatic validation of translations) and stating the format's purpose:
 
634
     * \code
 
635
     * QDate reportDate;
 
636
     * KGlobal::locale()->calendar()->setDate(reportDate, reportYear, reportMonth, 1);
 
637
     * dateFormat = i18nc("(kdedt-format) Report month and year in report header", "%B %Y"));
 
638
     * dateString = KGlobal::locale()->calendar()->formatDate(reportDate, dateFormat);
 
639
     * \endcode
 
640
     *
 
641
     * The date format string can be defined using either the KDE, POSIX or the Qt
 
642
     * subset of the UNICODE standards.
 
643
     *
 
644
     * The KDE standard closely follows the POSIX standard but with some exceptions.
 
645
     * Always use the KDE standard within KDE, but where interaction is required with
 
646
     * external POSIX compliant systems (e.g. Gnome, glibc, etc) the POSIX standard
 
647
     * should be used.  The UNICODE standard is provided for comaptability with QDate
 
648
     * and so is not yet the full standard, only what Qt currently supports.
 
649
     *
 
650
     * Date format strings are made up of date componants and string literals.
 
651
     * Date componants are prefixed by a % escape character and are made up of
 
652
     * optional padding and case modifier flags, an optional width value, and a
 
653
     * compulsary code for the actual date componant:
 
654
     *   %[Flags][Width][Componant]
 
655
     * e.g. %_^5Y
 
656
     * No spaces are allowed.
 
657
     *
 
658
     * The Flags can modify the padding character and/or case of the Date Componant.
 
659
     * The Flags are optional and may be combined and/or repeated in any order,
 
660
     * in which case the last Padding Flag and last Case Flag will be the
 
661
     * ones used.  The Flags must be immediately after the % and before any Width.
 
662
     *
 
663
     * The Width can modify how wide the date Componant is padded to.  The Width
 
664
     * is an optional interger value and must be after any Flags but before the
 
665
     * Componant.  If the Width is less than the minimum defined for a Componant
 
666
     * then the default minimum will be used instead.
 
667
     *
 
668
     * By default most numeric Date Componants are right-aligned with leading 0's.
 
669
     *
 
670
     * By default all string name fields are capital case and unpadded.
 
671
     *
 
672
     * The following Flags may be specified:
 
673
     * @li - (hyphen) no padding (e.g. 1 Jan and "%-j" = "1")
 
674
     * @li _ (underscore) pad with spaces (e.g. 1 Jan and "%-j" = "  1")
 
675
     * @li 0 (zero) pad with 0's  (e.g. 1 Jan and "%0j" = "001")
 
676
     * @li ^ (caret) make uppercase (e.g. 1 Jan and "%^B" = "JANUARY")
 
677
     * @li # (hash) invert case (e.g. 1 Jan and "%#B" = "???")
 
678
     *
 
679
     * The following Date Componants can be specified:
 
680
     * @li %Y the year to 4 digits (e.g. "1984" for 1984, "0584" for 584, "0084" for 84)
 
681
     * @li %C the 'century' portion of the year to 2 digits (e.g. "19" for 1984, "05" for 584, "00" for 84)
 
682
     * @li %y the lower 2 digits of the year to 2 digits (e.g. "84" for 1984, "05" for 2005)
 
683
     * @li %EY the full local era year (e.g. "2000 AD")
 
684
     * @li %EC the era name short form (e.g. "AD")
 
685
     * @li %Ey the year in era to 1 digit (e.g. 1 or 2000)
 
686
     * @li %m the month number to 2 digits (January="01", December="12")
 
687
     * @li %n the month number to 1 digit (January="1", December="12"), see notes!
 
688
     * @li %d the day number of the month to 2 digits (e.g. "01" on the first of March)
 
689
     * @li %e the day number of the month to 1 digit (e.g. "1" on the first of March)
 
690
     * @li %B the month name long form (e.g. "January")
 
691
     * @li %b the month name short form (e.g. "Jan" for January)
 
692
     * @li %h the month name short form (e.g. "Jan" for January)
 
693
     * @li %A the weekday name long form (e.g. "Wednesday" for Wednesday)
 
694
     * @li %a the weekday name short form (e.g. "Wed" for Wednesday)
 
695
     * @li %j the day of the year number to 3 digits (e.g. "001"  for 1 Jan)
 
696
     * @li %V the ISO week of the year number to 2 digits (e.g. "01"  for ISO Week 1)
 
697
     * @li %G the year number in long form of the ISO week of the year to 4 digits (e.g. "2004"  for 1 Jan 2005)
 
698
     * @li %g the year number in short form of the ISO week of the year to 2 digits (e.g. "04"  for 1 Jan 2005)
 
699
     * @li %u the day of the week number to 1 digit (e.g. "1"  for Monday)
 
700
     * @li %D the US short date format (e.g. "%m/%d/%y")
 
701
     * @li %F the ISO short date format (e.g. "%Y-%m-%d")
 
702
     * @li %x the KDE locale short date format
 
703
     * @li %% the literal "%"
 
704
     * @li %t a tab character
 
705
     *
 
706
     * Everything else in the format string will be taken as literal text.
 
707
     *
 
708
     * Examples:
 
709
     * "%Y-%m-%d" = "2009-01-01"
 
710
     * "%Y-%-m-%_4d" = "2009-1-   1"
 
711
     *
 
712
     * The following format codes behave differently in the KDE and POSIX standards
 
713
     * @li %e in GNU/POSIX is space padded to 2 digits, in KDE is not padded
 
714
     * @li %n in GNU/POSIX is newline, in KDE is short month number
 
715
     *
 
716
     * The following POSIX format codes are currently not supported:
 
717
     * @li %U US week number
 
718
     * @li %w US day of week
 
719
     * @li %W US week number
 
720
     * @li %O locale's alternative numeric symbols, in KDE is not supported
 
721
     *
 
722
     * %0 is not supported as the returned result is always in the locale's chosen numeric symbol digit set.
 
723
     *
 
724
     * @see formatDateComponent()
 
725
     * @param formatString the date format to use
 
726
     * @param formatStandard the standard the @p dateFormat uses, defaults to KDE Standard
 
727
     * @return The date as a localized string
 
728
     */
 
729
    QString formatDate(const QString &formatString,
 
730
                       KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
 
731
 
 
732
    /**
 
733
     * Returns a Date Component as a localized string in the requested format.
 
734
     *
 
735
     * See @ref formatting for more details on Date Formatting.
 
736
     *
 
737
     * Each format size may vary depending on Locale and Calendar System but will
 
738
     * generally match the format description.  Some formats may not be directly
 
739
     * valid but a sensible value will always be returned.
 
740
     *
 
741
     * For example for 2010-01-01 the KLocale::Month with en_US Locale and Gregorian calendar may return:
 
742
     *   KLocale::ShortNumber = "1"
 
743
     *   KLocale::LongNumber  = "01"
 
744
     *   KLocale::NarrowName  = "J"
 
745
     *   KLocale::ShortName   = "Jan"
 
746
     *   KLocale::LongName    = "January"
 
747
     *
 
748
     * @see formatDate()
 
749
     * @param component The date component to return
 
750
     * @param format The format to return the @p component in
 
751
     * @return The string form of the date component
 
752
     */
 
753
    QString formatDateComponent(KLocale::DateTimeComponent component, KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat) const;
 
754
 
 
755
    /**
 
756
     * Returns the Week as a localized string in the requested format
 
757
     * and Week Number System.
 
758
     *
 
759
     * See @ref formatting for more details on Date Formatting.
 
760
     *
 
761
     * For example for Week 1 with en_US Locale and Gregorian calendar may return:
 
762
     *   KLocale::ShortNumber = "1"
 
763
     *   KLocale::LongNumber  = "01"
 
764
     *
 
765
     * This is the equivalent of the POSIX date format code "%" and "%"
 
766
     *
 
767
     * @see week()
 
768
     * @see formatWeeksInYear()
 
769
     * @see formatDateComponent()
 
770
     * @param weekNumberSystem the Week Number System to use
 
771
     * @param format The format to return
 
772
     * @return The string form of the week number
 
773
     */
 
774
    QString formatWeek(KLocale::WeekNumberSystem weekNumberSystem, KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat) const;
 
775
 
 
776
    /**
 
777
     * Returns the Weeks In Year as a localized string in the requested format
 
778
     * and Week Number System.
 
779
     *
 
780
     * See @ref formatting for more details on Date Formatting.
 
781
     *
 
782
     * For example for Week 1 with en_US Locale and Gregorian calendar may return:
 
783
     *   KLocale::ShortNumber = "1"
 
784
     *   KLocale::LongNumber  = "01"
 
785
     *
 
786
     * This is the equivalent of the POSIX date format code "%" and "%"
 
787
     *
 
788
     * @see week()
 
789
     * @see weeksInYear()
 
790
     * @see formatWeek()
 
791
     * @see formatDateComponent()
 
792
     * @param format The format to return
 
793
     * @return The string form of the weeks in year
 
794
     */
 
795
    QString formatWeeksInYear(KLocale::WeekNumberSystem weekNumberSystem, KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat) const;
 
796
 
 
797
    /**
 
798
     * Converts a localized date string to a KLocalizedDate using either the
 
799
     * Global Calendar System and Locale, or the provided Calendar System.
 
800
     *
 
801
     * See @ref parsing for more details on Date Parsing from strings.
 
802
     *
 
803
     * This method is more liberal and will return a valid date if the
 
804
     * @p dateString matches any of the KLocale::ReadDateFlags formats
 
805
     * for the Locale.
 
806
     *
 
807
     * If you require a certain KLocale::ReadDateFlags format or a customized
 
808
     * format string, use one of the other readDate() methods.
 
809
     *
 
810
     * @param dateString the string to parse
 
811
     * @param parseMode how strictly to apply the locale formats to the @p dateString
 
812
     * @param calendar the Calendar System to use when parsing the date
 
813
     * @return the localized date parsed from the string
 
814
     */
 
815
    static KLocalizedDate readDate(const QString &dateString,
 
816
                                   KLocale::DateTimeParseMode parseMode = KLocale::LiberalParsing,
 
817
                                   const KCalendarSystem *calendar = 0);
 
818
 
 
819
    /**
 
820
     * Converts a localized date string to a KLocalizedDate using either the
 
821
     * Global Calendar System and Locale, or the provided Calendar System.
 
822
     *
 
823
     * See @ref parsing for more details on Date Parsing from strings.
 
824
     *
 
825
     * This method is stricter and will return a valid date only if the
 
826
     * @p dateString matches one of the @p dateFlags formats requested.
 
827
     *
 
828
     * If you require any KLocale::ReadDateFlags format or a customized format
 
829
     * string, use one of the other readDate() methods.
 
830
     *
 
831
     * @param dateString the string to parse
 
832
     * @param formatFlags the locale format(s) to try parse the string with
 
833
     * @param parseMode how strictly to apply the @p formatFlags to the @p dateString
 
834
     * @param calendar the Calendar System to use when parsing the date
 
835
     * @return the localized date parsed from the string
 
836
     */
 
837
    static KLocalizedDate readDate(const QString &dateString,
 
838
                                   KLocale::ReadDateFlags formatFlags,
 
839
                                   KLocale::DateTimeParseMode parseMode = KLocale::LiberalParsing,
 
840
                                   const KCalendarSystem *calendar = 0);
 
841
 
 
842
    /**
 
843
     * Converts a localized date string to a KLocalizedDate using either the
 
844
     * Global Calendar System and Locale, or the provided Calendar System.
 
845
     *
 
846
     * See @ref parsing for more details on Date Parsing from strings.
 
847
     *
 
848
     * This method allows you to define your own date format to parse the date
 
849
     * string with.
 
850
     *
 
851
     * If you require one of the standard any KLocale::ReadDateFlags formats
 
852
     * then use one of the other readDate() methods.
 
853
     *
 
854
     * @param dateString the string to parse
 
855
     * @param dateFormat the date format to try parse the string with
 
856
     * @param parseMode how strictly to apply the @p dateFormat to the @p dateString
 
857
     * @param formatStandard the standard the @p dateFormat format uses
 
858
     * @param calendar the Calendar System to use when parsing the date
 
859
     * @return the localized date parsed from the string
 
860
     */
 
861
    static KLocalizedDate readDate(const QString &dateString,
 
862
                                   const QString &dateFormat,
 
863
                                   KLocale::DateTimeParseMode parseMode = KLocale::LiberalParsing,
 
864
                                   KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat,
 
865
                                   const KCalendarSystem *calendar = 0);
 
866
 
 
867
    /**
 
868
     * Returns a KLocalizedDate containing a date @p years years later.
 
869
     *
 
870
     * @see addYearsTo()
 
871
     * @see addMonths() addDays()
 
872
     * @see dateDifference() yearsDifference()
 
873
     * @param years The number of years to add
 
874
     * @return The new date, null date if any errors
 
875
     */
 
876
    KLocalizedDate addYears(int years) const;
 
877
 
 
878
    /**
 
879
     * Add years onto this date instance.
 
880
     *
 
881
     * If the result of the addition is invalid in the current Calendar System
 
882
     * then the date will become invalid.
 
883
     *
 
884
     * @see addYears()
 
885
     * @see addMonthsTo() addDaysTo()
 
886
     * @see dateDifference() yearsDifference()
 
887
     * @param years The number of years to add
 
888
     * @return if the resulting date is valid
 
889
     */
 
890
    bool addYearsTo(int years);
 
891
 
 
892
    /**
 
893
     * Returns a KLocalizedDate containing a date @p months months later.
 
894
     *
 
895
     * @see addMonthsTo()
 
896
     * @see addYears() addDays()
 
897
     * @see dateDifference() yearsDifference()
 
898
     * @param months number of months to add
 
899
     * @return The new date, null date if any errors
 
900
     */
 
901
    KLocalizedDate addMonths(int months) const;
 
902
 
 
903
    /**
 
904
     * Add months onto this date instance.
 
905
     *
 
906
     * If the result of the addition is invalid in the current Calendar System
 
907
     * then the date will become invalid.
 
908
     *
 
909
     * @see addMonths()
 
910
     * @see addYearsTo() addDaysTo()
 
911
     * @see dateDifference() yearsDifference()
 
912
     * @param months The number of months to add
 
913
     * @return if the resulting date is valid
 
914
     */
 
915
    bool addMonthsTo(int months);
 
916
 
 
917
    /**
 
918
     * Returns a KLocalizedDate containing a date @p days days later.
 
919
     *
 
920
     * @see addDaysTo()
 
921
     * @see addYears() addMonths()
 
922
     * @see dateDifference() yearsDifference()
 
923
     * @param days number of days to add
 
924
     * @return The new date, null date if any errors
 
925
     */
 
926
    KLocalizedDate addDays(int days) const;
 
927
 
 
928
    /**
 
929
     * Add days onto this date instance.
 
930
     *
 
931
     * If the result of the addition is invalid in the current Calendar System
 
932
     * then the date will become invalid.
 
933
     *
 
934
     * @see addDays()
 
935
     * @see addYearsTo(), addMonthsTo()
 
936
     * @see dateDifference() yearsDifference()
 
937
     * @param days The number of days to add
 
938
     * @return if the resulting date is valid
 
939
     */
 
940
    bool addDaysTo(int days);
 
941
 
 
942
    /**
 
943
     * Returns the difference between this and another date in years, months and days
 
944
     * in the current Calendar System.
 
945
     *
 
946
     * The difference is always calculated from the earlier date to the later
 
947
     * date in year, month and day order, with the @p direction parameter
 
948
     * indicating which direction the difference is applied from this date.
 
949
     * In other words, this difference can be added onto the earlier date in
 
950
     * year, month, day order to reach the later date.
 
951
     *
 
952
     * For example, the difference between 2010-06-10 and 2012-09-5 is 2 years,
 
953
     * 2 months and 26 days.  Note that the difference between two last days of
 
954
     * the month is always 1 month, e.g. 2010-01-31 to 2010-02-28 is 1 month
 
955
     * not 28 days.
 
956
     *
 
957
     * @see addYears() addMonths() addDays()
 
958
     * @see yearsDifference() monthsDifference() daysDifference()
 
959
     * @param toDate The date to end at
 
960
     * @param yearsDiff Returns number of years difference
 
961
     * @param monthsDiff Returns number of months difference
 
962
     * @param daysDiff Returns number of days difference
 
963
     * @param direction Returns direction of difference, 1 if this Date <= toDate, -1 otherwise
 
964
     */
 
965
    void dateDifference(const KLocalizedDate &toDate,
 
966
                        int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
 
967
 
 
968
    /**
 
969
     * Returns the difference between this and another date in years, months and days
 
970
     * in the current Calendar System.
 
971
     *
 
972
     * The difference is always calculated from the earlier date to the later
 
973
     * date in year, month and day order, with the @p direction parameter
 
974
     * indicating which direction the difference is applied from this date.
 
975
     * In other words, this difference can be added onto the earlier date in
 
976
     * year, month, day order to reach the later date.
 
977
     *
 
978
     * For example, the difference between 2010-06-10 and 2012-09-5 is 2 years,
 
979
     * 2 months and 26 days.  Note that the difference between two last days of
 
980
     * the month is always 1 month, e.g. 2010-01-31 to 2010-02-28 is 1 month
 
981
     * not 28 days.
 
982
     *
 
983
     * @see addYears() addMonths() addDays()
 
984
     * @see yearsDifference() monthsDifference() daysDifference()
 
985
     * @param toDate The date to end at
 
986
     * @param yearsDiff Returns number of years difference
 
987
     * @param monthsDiff Returns number of months difference
 
988
     * @param daysDiff Returns number of days difference
 
989
     * @param direction Returns direction of difference, 1 if this Date <= toDate, -1 otherwise
 
990
     */
 
991
    void dateDifference(const QDate &toDate,
 
992
                        int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
 
993
 
 
994
    /**
 
995
     * Returns the difference between this and another date in completed calendar years
 
996
     * in the current Calendar System.
 
997
     * 
 
998
     * The returned value will be negative if @p toDate < this date.
 
999
     *
 
1000
     * For example, the difference between 2010-06-10 and 2012-09-5 is 2 years.
 
1001
     *
 
1002
     * @see addYears()
 
1003
     * @see dateDifference() monthsDifference() daysDifference()
 
1004
     * @param toDate The date to end at
 
1005
     * @return The number of years difference
 
1006
     */
 
1007
    int yearsDifference(const KLocalizedDate &toDate) const;
 
1008
 
 
1009
    /**
 
1010
     * Returns the difference between this and another date in completed calendar years
 
1011
     * in the current Calendar System.
 
1012
     *
 
1013
     * The returned value will be negative if @p toDate < this date.
 
1014
     *
 
1015
     * For example, the difference between 2010-06-10 and 2012-09-5 is 2 years.
 
1016
     *
 
1017
     * @see addYears()
 
1018
     * @see dateDifference() monthsDifference() daysDifference()
 
1019
     * @param toDate The date to end at
 
1020
     * @return The number of years difference
 
1021
     */
 
1022
    int yearsDifference(const QDate &toDate) const;
 
1023
 
 
1024
    /**
 
1025
     * Returns the difference between this and another date in completed calendar months
 
1026
     * in the current Calendar System.
 
1027
     *
 
1028
     * The returned value will be negative if @p toDate < this date.
 
1029
     *
 
1030
     * For example, the difference between 2010-06-10 and 2012-09-5 is 26 months.
 
1031
     * Note that the difference between two last days of the month is always 1
 
1032
     * month, e.g. 2010-01-31 to 2010-02-28 is 1 month not 28 days.
 
1033
     *
 
1034
     * @see addMonths()
 
1035
     * @see dateDifference() yearsDifference() daysDifference()
 
1036
     * @param toDate The date to end at
 
1037
     * @return The number of months difference
 
1038
     */
 
1039
    int monthsDifference(const KLocalizedDate &toDate) const;
 
1040
 
 
1041
    /**
 
1042
     * Returns the difference between this and another date in completed calendar months
 
1043
     * in the current Calendar System.
 
1044
     *
 
1045
     * The returned value will be negative if @p toDate < this date.
 
1046
     *
 
1047
     * For example, the difference between 2010-06-10 and 2012-09-5 is 26 months.
 
1048
     * Note that the difference between two last days of the month is always 1
 
1049
     * month, e.g. 2010-01-31 to 2010-02-28 is 1 month not 28 days.
 
1050
     *
 
1051
     * @see addMonths()
 
1052
     * @see dateDifference() yearsDifference() daysDifference()
 
1053
     * @param toDate The date to end at
 
1054
     * @return The number of months difference
 
1055
     */
 
1056
    int monthsDifference(const QDate &toDate) const;
 
1057
 
 
1058
    /**
 
1059
     * Returns the difference between this and another date in days
 
1060
     * The returned value will be negative if @p toDate < this date.
 
1061
     *
 
1062
     * @see addDays()
 
1063
     * @see dateDifference() yearsDifference() monthsDifference()
 
1064
     * @param toDate The date to end at
 
1065
     * @return The number of days difference
 
1066
     */
 
1067
    int daysDifference(const KLocalizedDate &toDate) const;
 
1068
 
 
1069
    /**
 
1070
     * Returns the difference between this and another date in days
 
1071
     * The returned value will be negative if @p toDate < this date.
 
1072
     *
 
1073
     * @see addDays()
 
1074
     * @see dateDifference() yearsDifference() monthsDifference()
 
1075
     * @param toDate The date to end at
 
1076
     * @return The number of days difference
 
1077
     */
 
1078
    int daysDifference(const QDate &toDate) const;
 
1079
 
 
1080
    /**
 
1081
     * Returns a KLocalizedDate containing the first day of the currently set year
 
1082
     *
 
1083
     * @see lastDayOfYear()
 
1084
     * @return The first day of the year
 
1085
     */
 
1086
    KLocalizedDate firstDayOfYear() const;
 
1087
 
 
1088
    /**
 
1089
     * Returns a KLocalizedDate containing the last day of the currently set year
 
1090
     *
 
1091
     * @see firstDayOfYear()
 
1092
     * @return The last day of the year
 
1093
     */
 
1094
    KLocalizedDate lastDayOfYear() const;
 
1095
 
 
1096
    /**
 
1097
     * Returns a KLocalizedDate containing the first day of the currently set month
 
1098
     *
 
1099
     * @see lastDayOfMonth()
 
1100
     * @return The first day of the month
 
1101
     */
 
1102
    KLocalizedDate firstDayOfMonth() const;
 
1103
 
 
1104
    /**
 
1105
     * Returns a KLocalizedDate containing the last day of the currently set month
 
1106
     *
 
1107
     * @see firstDayOfMonth()
 
1108
     * @return The last day of the month
 
1109
     */
 
1110
    KLocalizedDate lastDayOfMonth() const;
 
1111
 
 
1112
    /**
 
1113
     * KLocalizedDate equality operator
 
1114
     *
 
1115
     * @param other the date to compare
 
1116
     */
 
1117
    bool operator==(const KLocalizedDate &other) const;
 
1118
 
 
1119
    /**
 
1120
     * QDate equality operator
 
1121
     *
 
1122
     * @param other the date to compare
 
1123
     */
 
1124
    bool operator==(const QDate &other) const;
 
1125
 
 
1126
    /**
 
1127
     * KLocalizedDate inequality operator
 
1128
     *
 
1129
     * @param other the date to compare
 
1130
     */
 
1131
    bool operator!=(const KLocalizedDate &other) const;
 
1132
 
 
1133
    /**
 
1134
     * QDate inequality operator
 
1135
     *
 
1136
     * @param other the date to compare
 
1137
     */
 
1138
    bool operator!=(const QDate &other) const;
 
1139
 
 
1140
    /**
 
1141
     * KLocalizedDate less than operator
 
1142
     *
 
1143
     * @param other the date to compare
 
1144
     */
 
1145
    bool operator<(const KLocalizedDate &other) const;
 
1146
 
 
1147
    /**
 
1148
     * QDate less than operator
 
1149
     *
 
1150
     * @param other the date to compare
 
1151
     */
 
1152
    bool operator<(const QDate &other) const;
 
1153
 
 
1154
    /**
 
1155
     * KLocalizedDate less than or equal to operator
 
1156
     *
 
1157
     * @param other the date to compare
 
1158
     */
 
1159
    bool operator<=(const KLocalizedDate &other) const;
 
1160
 
 
1161
    /**
 
1162
     * QDate less than or equal to operator
 
1163
     *
 
1164
     * @param other the date to compare
 
1165
     */
 
1166
    bool operator<=(const QDate &other) const;
 
1167
 
 
1168
    /**
 
1169
     * KLocalizedDate greater than operator
 
1170
     *
 
1171
     * @param other the date to compare
 
1172
     */
 
1173
    bool operator>(const KLocalizedDate &other) const;
 
1174
 
 
1175
    /**
 
1176
     * QDate greater than operator
 
1177
     *
 
1178
     * @param other the date to compare
 
1179
     */
 
1180
    bool operator>(const QDate &other) const;
 
1181
 
 
1182
    /**
 
1183
     * KLocalizedDate greater than or equal to operator
 
1184
     *
 
1185
     * @param other the date to compare
 
1186
     */
 
1187
    bool operator>=(const KLocalizedDate &other) const;
 
1188
 
 
1189
    /**
 
1190
     * QDate greater than or equal to operator
 
1191
     *
 
1192
     * @param other the date to compare
 
1193
     */
 
1194
    bool operator>=(const QDate &other) const;
 
1195
 
 
1196
private:
 
1197
 
 
1198
    friend QDataStream KDECORE_EXPORT &operator<<(QDataStream &out, const KLocalizedDate &date);
 
1199
    friend QDataStream KDECORE_EXPORT &operator>>(QDataStream &in, KLocalizedDate &date);
 
1200
    friend QDebug KDECORE_EXPORT operator<<(QDebug, const KLocalizedDate &);
 
1201
 
 
1202
    QSharedDataPointer<KLocalizedDatePrivate> d;
 
1203
};
 
1204
 
 
1205
Q_DECLARE_METATYPE(KLocalizedDate)
 
1206
 
 
1207
/**
 
1208
 * Data stream output operator
 
1209
 *
 
1210
 * @param other the date to compare
 
1211
 */
 
1212
QDataStream KDECORE_EXPORT &operator<<(QDataStream &out, const KLocalizedDate &date);
 
1213
 
 
1214
/**
 
1215
 * Data stream input operator
 
1216
 *
 
1217
 * @param other the date to compare
 
1218
 */
 
1219
QDataStream KDECORE_EXPORT &operator>>(QDataStream &in, KLocalizedDate &date);
 
1220
 
 
1221
/**
 
1222
 * Debug stream output operator
 
1223
 *
 
1224
 * @param other the date to print
 
1225
 */
 
1226
QDebug KDECORE_EXPORT operator<<(QDebug, const KLocalizedDate &);
 
1227
 
 
1228
#endif // KDATE_H