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

KDECore

kcalendarsystem.h
Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es>
00003     Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
00004     Copyright 2007, 2009, 2010 John Layt <john@layt.net>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KCALENDARSYSTEM_H
00023 #define KCALENDARSYSTEM_H
00024 
00025 #include <kdecore_export.h>
00026 #include "klocale.h"  // needed for enums
00027 #include "kglobal.h"
00028 
00029 #include <QtCore/QStringList>
00030 #include <QtCore/QDate>
00031 
00032 class KCalendarSystemPrivate;
00033 class KCalendarEra;
00034 
00040 class KDECORE_EXPORT KCalendarSystem
00041 {
00042 public:
00043 
00047     enum StringFormat {
00048         ShortFormat,      
00049         LongFormat        
00050     };
00051 
00055     enum MonthNameFormat {
00056         ShortName,                
00057         LongName,                 
00058         ShortNamePossessive,      
00059         LongNamePossessive,       
00060         NarrowName                
00061     };
00062 
00066     enum WeekDayNameFormat {
00067         ShortDayName,                
00068         LongDayName,                 
00069         NarrowDayName                
00070     };
00071 
00072     //KDE5 remove
00083     KDE_DEPRECATED static KCalendarSystem *create(const QString & calType = QLatin1String("gregorian"),
00084                                                   const KLocale * locale = 0);
00085 
00086     //KDE5 remove
00101     KDE_DEPRECATED static KCalendarSystem *create(const QString & calType, KSharedConfig::Ptr config,
00102                                                   const KLocale * locale = 0);
00103 
00104     //KDE5 add default value to calendarSystem
00114     static KCalendarSystem *create(KLocale::CalendarSystem calendarSystem,
00115                                    const KLocale *locale = 0);
00116 
00129     static KCalendarSystem *create(KLocale::CalendarSystem calendarSystem, KSharedConfig::Ptr config,
00130                                    const KLocale *locale = 0);
00131 
00132     //KDE5 remove
00140     KDE_DEPRECATED static QStringList calendarSystems();
00141 
00149     static QList<KLocale::CalendarSystem> calendarSystemsList();
00150 
00151     //KDE5 remove
00163     KDE_DEPRECATED static QString calendarLabel(const QString &calendarType);
00164 
00177     static QString calendarLabel(KLocale::CalendarSystem calendarSystem, const KLocale *locale = KGlobal::locale());
00178 
00179     //KDE5 Remove
00190     KDE_DEPRECATED static KLocale::CalendarSystem calendarSystemForCalendarType(const QString &calendarType);
00191 
00192     //KDE5 Remove
00202     static KLocale::CalendarSystem calendarSystem(const QString &calendarType);
00203 
00204     //KDE5 remove
00214     static QString calendarType(KLocale::CalendarSystem calendarSystem);
00215 
00221     explicit KCalendarSystem(const KLocale *locale = 0);
00222 
00231     explicit KCalendarSystem(const KSharedConfig::Ptr config, const KLocale *locale = 0);
00232 
00236     virtual ~KCalendarSystem();
00237 
00245     KDE_DEPRECATED virtual QString calendarType() const = 0;
00246 
00247     //KDE5 make virtual?
00255     KLocale::CalendarSystem calendarSystem() const;
00256 
00257     //KDE5 make virtual?
00265     QString calendarLabel() const;
00266 
00282     virtual QDate epoch() const;
00283 
00294     virtual QDate earliestValidDate() const;
00295 
00304     virtual QDate latestValidDate() const;
00305 
00314     virtual bool isValid(int year, int month, int day) const = 0;
00315 
00316     //KDE5 make virtual?
00326     bool isValid(int year, int dayOfYear) const;
00327 
00328     //KDE5 make virtual?
00340     bool isValid(const QString &eraName, int yearInEra, int month, int day) const;
00341 
00342     //KDE5 make virtual?
00353     bool isValidIsoWeekDate(int year, int isoWeekNumber, int dayOfIsoWeek) const;
00354 
00361     virtual bool isValid(const QDate &date) const;
00362 
00375     virtual bool setDate(QDate &date, int year, int month, int day) const;
00376 
00377     //KDE5 make virtual?
00388     bool setDate(QDate &date, int year, int dayOfYear) const;
00389 
00390     //KDE5 make virtual?
00403     bool setDate(QDate &date, QString eraName, int yearInEra, int month, int day) const;
00404 
00405     //KDE5 make virtual?
00417     bool setDateIsoWeek(QDate &date, int year, int isoWeekNumber, int dayOfIsoWeek) const;
00418 
00435     KDE_DEPRECATED virtual bool setYMD(QDate &date, int y, int m, int d) const;
00436 
00437     //KDE5 make virtual?
00448     void getDate(const QDate date, int *year, int *month, int *day) const;
00449 
00456     virtual int year(const QDate &date) const;
00457 
00464     virtual int month(const QDate &date) const;
00465 
00472     virtual int day(const QDate &date) const;
00473 
00474     //KDE5 make virtual?
00485     QString eraName(const QDate &date, StringFormat format = ShortFormat) const;
00486 
00487     //KDE5 make virtual?
00498     QString eraYear(const QDate &date, StringFormat format = ShortFormat) const;
00499 
00500     //KDE5 make virtual?
00510     int yearInEra(const QDate &date) const;
00511 
00519     virtual QDate addYears(const QDate &date, int nyears) const;
00520 
00528     virtual QDate addMonths(const QDate &date, int nmonths) const;
00529 
00537     virtual QDate addDays(const QDate &date, int ndays) const;
00538 
00539     //KDE5 make virtual?
00558     void dateDifference(const QDate &fromDate, const QDate &toDate,
00559                         int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
00560 
00561     //KDE5 make virtual?
00572     int yearsDifference(const QDate &fromDate, const QDate &toDate) const;
00573 
00574     //KDE5 make virtual?
00587     int monthsDifference(const QDate &fromDate, const QDate &toDate) const;
00588 
00589     //KDE5 make virtual?
00598     int daysDifference(const QDate &fromDate, const QDate &toDate) const;
00599 
00606     virtual int monthsInYear(const QDate &date) const;
00607 
00608     //KDE5 make virtual?
00617     int monthsInYear(int year) const;
00618 
00625     virtual int weeksInYear(const QDate &date) const;
00626 
00627     //KDE5 Merge with virtual weeksInYear with default
00642     int weeksInYear(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem) const;
00643 
00650     virtual int weeksInYear(int year) const;
00651 
00652     //KDE5 Merge with virtual weeksInYear with default
00667     int weeksInYear(int year, KLocale::WeekNumberSystem weekNumberSystem) const;
00668 
00675     virtual int daysInYear(const QDate &date) const;
00676 
00677     //KDE5 make virtual?
00686     int daysInYear(int year) const;
00687 
00694     virtual int daysInMonth(const QDate &date) const;
00695 
00696     //KDE5 make virtual?
00706     int daysInMonth(int year, int month) const;
00707 
00714     virtual int daysInWeek(const QDate &date) const;
00715 
00724     virtual int dayOfYear(const QDate &date) const;
00725 
00736     virtual int dayOfWeek(const QDate &date) const;
00737 
00753     KDE_DEPRECATED virtual int weekNumber(const QDate &date, int *yearNum = 0) const;
00754 
00755     //KDE5 Make virtual?
00773     int week(const QDate &date, int *yearNum = 0) const;
00774 
00775     //KDE5 Make virtual?
00796     int week(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem, int *yearNum = 0) const;
00797 
00807     virtual bool isLeapYear(int year) const = 0;
00808 
00818     virtual bool isLeapYear(const QDate &date) const;
00819 
00820     //KDE5 Make virtual?
00829     QDate firstDayOfYear(int year) const;
00830 
00831     //KDE5 Make virtual?
00840     QDate lastDayOfYear(int year) const;
00841 
00842     //KDE5 Make virtual?
00851     QDate firstDayOfYear(const QDate &date = QDate::currentDate()) const;
00852 
00853     //KDE5 Make virtual?
00862     QDate lastDayOfYear(const QDate &date = QDate::currentDate()) const;
00863 
00864     //KDE5 Make virtual?
00874     QDate firstDayOfMonth(int year, int month) const;
00875 
00876     //KDE5 Make virtual?
00886     QDate lastDayOfMonth(int year, int month) const;
00887 
00888     //KDE5 Make virtual?
00897     QDate firstDayOfMonth(const QDate &date = QDate::currentDate()) const;
00898 
00899     //KDE5 Make virtual?
00908     QDate lastDayOfMonth(const QDate &date = QDate::currentDate()) const;
00909 
00919     virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const = 0;
00920 
00928     virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
00929 
00938     virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const = 0;
00939 
00947     virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
00948 
00959     KDE_DEPRECATED virtual QString yearString(const QDate &date, StringFormat format = LongFormat) const;
00960 
00971     KDE_DEPRECATED virtual QString monthString(const QDate &pDate, StringFormat format = LongFormat) const;
00972 
00983     KDE_DEPRECATED virtual QString dayString(const QDate &pDate, StringFormat format = LongFormat) const;
00984 
00985     //KDE5 make virtual?
00997     KDE_DEPRECATED QString yearInEraString(const QDate &date, StringFormat format = ShortFormat) const;
00998 
00999     //KDE5 make virtual?
01012     KDE_DEPRECATED QString dayOfYearString(const QDate &pDate, StringFormat format = LongFormat) const;
01013 
01014     //KDE5 make virtual?
01026     KDE_DEPRECATED QString dayOfWeekString(const QDate &pDate) const;
01027 
01028     //KDE5 make virtual?
01041     KDE_DEPRECATED QString weekNumberString(const QDate &pDate, StringFormat format = LongFormat) const;
01042 
01043     //KDE5 make virtual?
01056     KDE_DEPRECATED QString monthsInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
01057 
01058     //KDE5 make virtual?
01071     KDE_DEPRECATED QString weeksInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
01072 
01073     //KDE5 make virtual?
01086     KDE_DEPRECATED QString daysInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
01087 
01088     //KDE5 make virtual?
01101     KDE_DEPRECATED QString daysInMonthString(const QDate &pDate, StringFormat format = LongFormat) const;
01102 
01103     //KDE5 make virtual?
01115     KDE_DEPRECATED QString daysInWeekString(const QDate &date) const;
01116 
01117     //KDE5 make protected or remove?
01127     virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
01128 
01129     //KDE5 make protected or remove?
01139     virtual int monthStringToInteger(const QString &sNum, int &iLength) const;
01140 
01141     //KDE5 make protected or remove?
01151     virtual int dayStringToInteger(const QString &sNum, int &iLength) const;
01152 
01169     virtual QString formatDate(const QDate &fromDate, KLocale::DateFormat toFormat = KLocale::LongDate) const;
01170 
01171     //KDE5 Make virtual
01288     QString formatDate(const QDate &fromDate, const QString &toFormat,
01289                        KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
01290 
01291     //KDE5 Make virtual
01308     QString formatDate(const QDate &fromDate, const QString &toFormat, KLocale::DigitSet digitSet,
01309                        KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
01310 
01311     //KDE5 Make virtual
01330     QString formatDate(const QDate &date, KLocale::DateTimeComponent component,
01331                        KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat,
01332                        KLocale::WeekNumberSystem weekNumberSystem = KLocale::DefaultWeekNumber) const;
01333 
01350     virtual QDate readDate(const QString &str, bool *ok = 0) const;
01351 
01370     virtual QDate readDate(const QString &str, KLocale::ReadDateFlags flags, bool *ok = 0) const;
01371 
01385     virtual QDate readDate(const QString &dateString, const QString &dateFormat, bool *ok = 0) const;
01386 
01387     //KDE5 Make virtual
01447     QDate readDate(const QString &dateString, const QString &dateFormat, bool *ok,
01448                    KLocale::DateTimeFormatStandard formatStandard) const;
01449 
01450     //KDE5 Make virtual
01480     int shortYearWindowStartYear() const;
01481 
01482     //KDE5 Make virtual
01499     int applyShortYearWindow(int inputYear) const;
01500 
01513     virtual int weekStartDay() const;
01514 
01526     KDE_DEPRECATED virtual int weekDayOfPray() const = 0;
01527 
01533     virtual bool isLunar() const = 0;
01534 
01540     virtual bool isLunisolar() const = 0;
01541 
01547     virtual bool isSolar() const = 0;
01548 
01557     virtual bool isProleptic() const = 0;
01558 
01559 protected:
01560 
01577     virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const = 0;
01578 
01595     virtual bool dateToJulianDay(int year, int month, int day, int &jd) const = 0;
01596 
01619     const KLocale *locale() const;
01620 
01628     KDE_DEPRECATED void setMaxMonthsInYear(int maxMonths);
01629 
01637     KDE_DEPRECATED void setMaxDaysInWeek(int maxDays);
01638 
01648     KDE_DEPRECATED void setHasYear0(bool hasYear0);
01649 
01659     KCalendarSystem(KCalendarSystemPrivate &dd,
01660                     const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
01661                     const KLocale *locale = 0);
01662 
01663 private:
01664     //Required for shared d-pointer as already private, remove in KDE5
01665     friend class KCalendarSystemCoptic;
01666     friend class KCalendarSystemEthiopian;
01667     friend class KCalendarSystemGregorian;
01668     friend class KCalendarSystemHebrew;
01669     friend class KCalendarSystemIndianNational;
01670     friend class KCalendarSystemIslamicCivil;
01671     friend class KCalendarSystemJalali;
01672     friend class KCalendarSystemJapanese;
01673     friend class KCalendarSystemJulian;
01674     friend class KCalendarSystemMinguo;
01675     friend class KCalendarSystemQDate;
01676     friend class KCalendarSystemThai;
01677     //Other friends that need access to protected/private functions
01678     friend class KLocalizedDate;
01679     friend class KLocalizedDatePrivate;
01680     friend class KDateTimeParser;
01681     friend class KDateTable;
01682 
01683     // Era functions needed by friends, may be made public later if needed in KCM
01684     QList<KCalendarEra> *eraList() const;
01685     KCalendarEra era(const QDate &eraDate) const;
01686     KCalendarEra era(const QString &eraName, int yearInEra) const;
01687 
01688     Q_DISABLE_COPY(KCalendarSystem)
01689     KCalendarSystemPrivate * const d_ptr; // KDE5 make protected
01690     Q_DECLARE_PRIVATE(KCalendarSystem)
01691 };
01692 
01693 #endif

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

Skip menu "kdelibs"
  • 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
Generated for kdelibs by doxygen 1.7.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal