• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • date
kcalendarsystem.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es>
3 Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
4 Copyright 2007, 2009, 2010 John Layt <john@layt.net>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 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 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KCALENDARSYSTEM_H
23#define KCALENDARSYSTEM_H
24
25#include <kdecore_export.h>
26#include "klocale.h" // needed for enums
27#include "kglobal.h"
28
29#include <QtCore/QStringList>
30#include <QtCore/QDate>
31
32class KCalendarSystemPrivate;
33class KCalendarEra;
34
40class KDECORE_EXPORT KCalendarSystem
41{
42public:
43
47 enum StringFormat {
48 ShortFormat,
49 LongFormat
50 };
51
55 enum MonthNameFormat {
56 ShortName,
57 LongName,
58 ShortNamePossessive,
59 LongNamePossessive,
60 NarrowName
61 };
62
66 enum WeekDayNameFormat {
67 ShortDayName,
68 LongDayName,
69 NarrowDayName
70 };
71
72 //KDE5 remove
83 KDE_DEPRECATED static KCalendarSystem *create(const QString & calType = QLatin1String("gregorian"),
84 const KLocale * locale = 0);
85
86 //KDE5 remove
101 KDE_DEPRECATED static KCalendarSystem *create(const QString & calType, KSharedConfig::Ptr config,
102 const KLocale * locale = 0);
103
104 //KDE5 add default value to calendarSystem
114 static KCalendarSystem *create(KLocale::CalendarSystem calendarSystem,
115 const KLocale *locale = 0);
116
129 static KCalendarSystem *create(KLocale::CalendarSystem calendarSystem, KSharedConfig::Ptr config,
130 const KLocale *locale = 0);
131
132 //KDE5 remove
140 KDE_DEPRECATED static QStringList calendarSystems();
141
149 static QList<KLocale::CalendarSystem> calendarSystemsList();
150
151 //KDE5 remove
163 KDE_DEPRECATED static QString calendarLabel(const QString &calendarType);
164
177 static QString calendarLabel(KLocale::CalendarSystem calendarSystem, const KLocale *locale = KGlobal::locale());
178
179 //KDE5 Remove
190 KDE_DEPRECATED static KLocale::CalendarSystem calendarSystemForCalendarType(const QString &calendarType);
191
192 //KDE5 Remove
202 static KLocale::CalendarSystem calendarSystem(const QString &calendarType);
203
204 //KDE5 remove
214 static QString calendarType(KLocale::CalendarSystem calendarSystem);
215
221 explicit KCalendarSystem(const KLocale *locale = 0);
222
231 explicit KCalendarSystem(const KSharedConfig::Ptr config, const KLocale *locale = 0);
232
236 virtual ~KCalendarSystem();
237
245 KDE_DEPRECATED virtual QString calendarType() const = 0;
246
247 //KDE5 make virtual?
255 KLocale::CalendarSystem calendarSystem() const;
256
257 //KDE5 make virtual?
265 QString calendarLabel() const;
266
282 virtual QDate epoch() const;
283
294 virtual QDate earliestValidDate() const;
295
304 virtual QDate latestValidDate() const;
305
314 virtual bool isValid(int year, int month, int day) const = 0;
315
316 //KDE5 make virtual?
326 bool isValid(int year, int dayOfYear) const;
327
328 //KDE5 make virtual?
340 bool isValid(const QString &eraName, int yearInEra, int month, int day) const;
341
342 //KDE5 make virtual?
353 bool isValidIsoWeekDate(int year, int isoWeekNumber, int dayOfIsoWeek) const;
354
361 virtual bool isValid(const QDate &date) const;
362
375 virtual bool setDate(QDate &date, int year, int month, int day) const;
376
377 //KDE5 make virtual?
388 bool setDate(QDate &date, int year, int dayOfYear) const;
389
390 //KDE5 make virtual?
403 bool setDate(QDate &date, QString eraName, int yearInEra, int month, int day) const;
404
405 //KDE5 make virtual?
417 bool setDateIsoWeek(QDate &date, int year, int isoWeekNumber, int dayOfIsoWeek) const;
418
435 KDE_DEPRECATED virtual bool setYMD(QDate &date, int y, int m, int d) const;
436
437 //KDE5 make virtual?
448 void getDate(const QDate date, int *year, int *month, int *day) const;
449
456 virtual int year(const QDate &date) const;
457
464 virtual int month(const QDate &date) const;
465
472 virtual int day(const QDate &date) const;
473
474 //KDE5 make virtual?
485 QString eraName(const QDate &date, StringFormat format = ShortFormat) const;
486
487 //KDE5 make virtual?
498 QString eraYear(const QDate &date, StringFormat format = ShortFormat) const;
499
500 //KDE5 make virtual?
510 int yearInEra(const QDate &date) const;
511
519 virtual QDate addYears(const QDate &date, int nyears) const;
520
528 virtual QDate addMonths(const QDate &date, int nmonths) const;
529
537 virtual QDate addDays(const QDate &date, int ndays) const;
538
539 //KDE5 make virtual?
558 void dateDifference(const QDate &fromDate, const QDate &toDate,
559 int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
560
561 //KDE5 make virtual?
572 int yearsDifference(const QDate &fromDate, const QDate &toDate) const;
573
574 //KDE5 make virtual?
587 int monthsDifference(const QDate &fromDate, const QDate &toDate) const;
588
589 //KDE5 make virtual?
598 int daysDifference(const QDate &fromDate, const QDate &toDate) const;
599
606 virtual int monthsInYear(const QDate &date) const;
607
608 //KDE5 make virtual?
617 int monthsInYear(int year) const;
618
625 virtual int weeksInYear(const QDate &date) const;
626
627 //KDE5 Merge with virtual weeksInYear with default
642 int weeksInYear(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem) const;
643
650 virtual int weeksInYear(int year) const;
651
652 //KDE5 Merge with virtual weeksInYear with default
667 int weeksInYear(int year, KLocale::WeekNumberSystem weekNumberSystem) const;
668
675 virtual int daysInYear(const QDate &date) const;
676
677 //KDE5 make virtual?
686 int daysInYear(int year) const;
687
694 virtual int daysInMonth(const QDate &date) const;
695
696 //KDE5 make virtual?
706 int daysInMonth(int year, int month) const;
707
714 virtual int daysInWeek(const QDate &date) const;
715
724 virtual int dayOfYear(const QDate &date) const;
725
736 virtual int dayOfWeek(const QDate &date) const;
737
753 KDE_DEPRECATED virtual int weekNumber(const QDate &date, int *yearNum = 0) const;
754
755 //KDE5 Make virtual?
773 int week(const QDate &date, int *yearNum = 0) const;
774
775 //KDE5 Make virtual?
796 int week(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem, int *yearNum = 0) const;
797
807 virtual bool isLeapYear(int year) const = 0;
808
818 virtual bool isLeapYear(const QDate &date) const;
819
820 //KDE5 Make virtual?
829 QDate firstDayOfYear(int year) const;
830
831 //KDE5 Make virtual?
840 QDate lastDayOfYear(int year) const;
841
842 //KDE5 Make virtual?
851 QDate firstDayOfYear(const QDate &date = QDate::currentDate()) const;
852
853 //KDE5 Make virtual?
862 QDate lastDayOfYear(const QDate &date = QDate::currentDate()) const;
863
864 //KDE5 Make virtual?
874 QDate firstDayOfMonth(int year, int month) const;
875
876 //KDE5 Make virtual?
886 QDate lastDayOfMonth(int year, int month) const;
887
888 //KDE5 Make virtual?
897 QDate firstDayOfMonth(const QDate &date = QDate::currentDate()) const;
898
899 //KDE5 Make virtual?
908 QDate lastDayOfMonth(const QDate &date = QDate::currentDate()) const;
909
919 virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const = 0;
920
928 virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
929
938 virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const = 0;
939
947 virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
948
959 KDE_DEPRECATED virtual QString yearString(const QDate &date, StringFormat format = LongFormat) const;
960
971 KDE_DEPRECATED virtual QString monthString(const QDate &pDate, StringFormat format = LongFormat) const;
972
983 KDE_DEPRECATED virtual QString dayString(const QDate &pDate, StringFormat format = LongFormat) const;
984
985 //KDE5 make virtual?
997 KDE_DEPRECATED QString yearInEraString(const QDate &date, StringFormat format = ShortFormat) const;
998
999 //KDE5 make virtual?
1012 KDE_DEPRECATED QString dayOfYearString(const QDate &pDate, StringFormat format = LongFormat) const;
1013
1014 //KDE5 make virtual?
1026 KDE_DEPRECATED QString dayOfWeekString(const QDate &pDate) const;
1027
1028 //KDE5 make virtual?
1041 KDE_DEPRECATED QString weekNumberString(const QDate &pDate, StringFormat format = LongFormat) const;
1042
1043 //KDE5 make virtual?
1056 KDE_DEPRECATED QString monthsInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
1057
1058 //KDE5 make virtual?
1071 KDE_DEPRECATED QString weeksInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
1072
1073 //KDE5 make virtual?
1086 KDE_DEPRECATED QString daysInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
1087
1088 //KDE5 make virtual?
1101 KDE_DEPRECATED QString daysInMonthString(const QDate &pDate, StringFormat format = LongFormat) const;
1102
1103 //KDE5 make virtual?
1115 KDE_DEPRECATED QString daysInWeekString(const QDate &date) const;
1116
1117 //KDE5 make protected or remove?
1127 virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
1128
1129 //KDE5 make protected or remove?
1139 virtual int monthStringToInteger(const QString &sNum, int &iLength) const;
1140
1141 //KDE5 make protected or remove?
1151 virtual int dayStringToInteger(const QString &sNum, int &iLength) const;
1152
1169 virtual QString formatDate(const QDate &fromDate, KLocale::DateFormat toFormat = KLocale::LongDate) const;
1170
1171 //KDE5 Make virtual
1288 QString formatDate(const QDate &fromDate, const QString &toFormat,
1289 KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
1290
1291 //KDE5 Make virtual
1308 QString formatDate(const QDate &fromDate, const QString &toFormat, KLocale::DigitSet digitSet,
1309 KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
1310
1311 //KDE5 Make virtual
1330 QString formatDate(const QDate &date, KLocale::DateTimeComponent component,
1331 KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat,
1332 KLocale::WeekNumberSystem weekNumberSystem = KLocale::DefaultWeekNumber) const;
1333
1350 virtual QDate readDate(const QString &str, bool *ok = 0) const;
1351
1370 virtual QDate readDate(const QString &str, KLocale::ReadDateFlags flags, bool *ok = 0) const;
1371
1385 virtual QDate readDate(const QString &dateString, const QString &dateFormat, bool *ok = 0) const;
1386
1387 //KDE5 Make virtual
1447 QDate readDate(const QString &dateString, const QString &dateFormat, bool *ok,
1448 KLocale::DateTimeFormatStandard formatStandard) const;
1449
1450 //KDE5 Make virtual
1480 int shortYearWindowStartYear() const;
1481
1482 //KDE5 Make virtual
1499 int applyShortYearWindow(int inputYear) const;
1500
1513 virtual int weekStartDay() const;
1514
1526 KDE_DEPRECATED virtual int weekDayOfPray() const = 0;
1527
1533 virtual bool isLunar() const = 0;
1534
1540 virtual bool isLunisolar() const = 0;
1541
1547 virtual bool isSolar() const = 0;
1548
1557 virtual bool isProleptic() const = 0;
1558
1559protected:
1560
1577 virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const = 0;
1578
1595 virtual bool dateToJulianDay(int year, int month, int day, int &jd) const = 0;
1596
1619 const KLocale *locale() const;
1620
1628 KDE_DEPRECATED void setMaxMonthsInYear(int maxMonths);
1629
1637 KDE_DEPRECATED void setMaxDaysInWeek(int maxDays);
1638
1648 KDE_DEPRECATED void setHasYear0(bool hasYear0);
1649
1659 KCalendarSystem(KCalendarSystemPrivate &dd,
1660 const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
1661 const KLocale *locale = 0);
1662
1663private:
1664 //Required for shared d-pointer as already private, remove in KDE5
1665 friend class KCalendarSystemCoptic;
1666 friend class KCalendarSystemEthiopian;
1667 friend class KCalendarSystemGregorian;
1668 friend class KCalendarSystemHebrew;
1669 friend class KCalendarSystemIndianNational;
1670 friend class KCalendarSystemIslamicCivil;
1671 friend class KCalendarSystemJalali;
1672 friend class KCalendarSystemJapanese;
1673 friend class KCalendarSystemJulian;
1674 friend class KCalendarSystemMinguo;
1675 friend class KCalendarSystemQDate;
1676 friend class KCalendarSystemThai;
1677 //Other friends that need access to protected/private functions
1678 friend class KLocalizedDate;
1679 friend class KLocalizedDatePrivate;
1680 friend class KDateTimeParser;
1681 friend class KDateTable;
1682
1683 // Era functions needed by friends, may be made public later if needed in KCM
1684 QList<KCalendarEra> *eraList() const;
1685 KCalendarEra era(const QDate &eraDate) const;
1686 KCalendarEra era(const QString &eraName, int yearInEra) const;
1687
1688 Q_DISABLE_COPY(KCalendarSystem)
1689 KCalendarSystemPrivate * const d_ptr; // KDE5 make protected
1690 Q_DECLARE_PRIVATE(KCalendarSystem)
1691};
1692
1693#endif
KCalendarEra
Definition: kcalendarera_p.h:44
KCalendarSystemCoptic
Definition: kcalendarsystemcoptic_p.h:38
KCalendarSystemEthiopian
Definition: kcalendarsystemethiopian_p.h:39
KCalendarSystemGregorian
Definition: kcalendarsystemgregorian_p.h:43
KCalendarSystemHebrew
Definition: kcalendarsystemhebrew_p.h:42
KCalendarSystemIndianNational
Definition: kcalendarsystemindiannational_p.h:42
KCalendarSystemIslamicCivil
Definition: kcalendarsystemislamiccivil_p.h:44
KCalendarSystemJalali
Jalali calendar type implementation.
Definition: kcalendarsystemjalali_p.h:33
KCalendarSystemJapanese
Definition: kcalendarsystemjapanese_p.h:39
KCalendarSystemJulian
Definition: kcalendarsystemjulian_p.h:42
KCalendarSystemMinguo
Definition: kcalendarsystemminguo_p.h:39
KCalendarSystemPrivate
Definition: kcalendarsystemprivate_p.h:32
KCalendarSystemQDate
Definition: kcalendarsystemqdate_p.h:42
KCalendarSystemThai
Definition: kcalendarsystemthai_p.h:39
KCalendarSystem
KCalendarSystem abstract base class, provides support for local Calendar Systems in KDE.
Definition: kcalendarsystem.h:41
KCalendarSystem::StringFormat
StringFormat
Format for returned year number / month number / day number as string.
Definition: kcalendarsystem.h:47
KCalendarSystem::ShortFormat
@ ShortFormat
Short string format, e.g.
Definition: kcalendarsystem.h:48
KCalendarSystem::isLunisolar
virtual bool isLunisolar() const =0
Returns whether the calendar is lunisolar based.
KCalendarSystem::weekDayOfPray
virtual int weekDayOfPray() const =0
KCalendarSystem::MonthNameFormat
MonthNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:55
KCalendarSystem::ShortName
@ ShortName
Short name format, e.g.
Definition: kcalendarsystem.h:56
KCalendarSystem::LongNamePossessive
@ LongNamePossessive
Long name possessive format, e.g.
Definition: kcalendarsystem.h:59
KCalendarSystem::ShortNamePossessive
@ ShortNamePossessive
Short name possessive format, e.g.
Definition: kcalendarsystem.h:58
KCalendarSystem::LongName
@ LongName
Long name format, e.g.
Definition: kcalendarsystem.h:57
KCalendarSystem::isSolar
virtual bool isSolar() const =0
Returns whether the calendar is solar based.
KCalendarSystem::WeekDayNameFormat
WeekDayNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:66
KCalendarSystem::ShortDayName
@ ShortDayName
Short name format, e.g.
Definition: kcalendarsystem.h:67
KCalendarSystem::LongDayName
@ LongDayName
Long name format, e.g.
Definition: kcalendarsystem.h:68
KCalendarSystem::calendarType
virtual QString calendarType() const =0
KCalendarSystem::isLunar
virtual bool isLunar() const =0
Returns whether the calendar is lunar based.
KCalendarSystem::isProleptic
virtual bool isProleptic() const =0
Returns whether the calendar system is proleptic, i.e.
KDateTimeParser
Definition: kdatetimeparser_p.h:50
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:70
KLocale::WeekNumberSystem
WeekNumberSystem
Definition: klocale.h:815
KLocale::DefaultWeekNumber
@ DefaultWeekNumber
The system locale default.
Definition: klocale.h:816
KLocale::DigitSet
DigitSet
Definition: klocale.h:309
KLocale::DateTimeFormatStandard
DateTimeFormatStandard
Definition: klocale.h:829
KLocale::KdeFormat
@ KdeFormat
KDE Standard.
Definition: klocale.h:830
KLocale::ReadDateFlags
ReadDateFlags
Flags for readDate()
Definition: klocale.h:1249
KLocale::DateTimeComponent
DateTimeComponent
Definition: klocale.h:865
KLocale::DateFormat
DateFormat
Format for date string.
Definition: klocale.h:922
KLocale::LongDate
@ LongDate
Locale Long date format, e.g.
Definition: klocale.h:924
KLocale::CalendarSystem
CalendarSystem
Definition: klocale.h:780
KLocale::DateTimeComponentFormat
DateTimeComponentFormat
Definition: klocale.h:908
KLocale::DefaultComponentFormat
@ DefaultComponentFormat
The system locale default for the componant.
Definition: klocale.h:909
KLocalizedDate
A class representing a date localized using the local calendar system, language and formats.
Definition: klocalizeddate.h:139
KSharedPtr< KSharedConfig >
QList
Definition: kaboutdata.h:33
QStringList
QString
kdecore_export.h
kglobal.h
klocale.h
KGlobal::locale
KLocale * locale()
Returns the global locale object.
Definition: kglobal.cpp:170
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal