• Skip to content
  • Skip to link menu
KDE 4.6 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     };
00061 
00065     enum WeekDayNameFormat {
00066          ShortDayName,                
00067          LongDayName                  
00068     };
00069 
00070     //KDE5 remove
00081     static KCalendarSystem *create( const QString & calType = QLatin1String( "gregorian" ),
00082                                      const KLocale * locale = 0 );
00083 
00084     //KDE5 remove
00099     static KCalendarSystem *create( const QString & calType, KSharedConfig::Ptr config,
00100                                     const KLocale * locale = 0 );
00101 
00102     //KDE5 add default value to calendarSystem
00112     static KCalendarSystem *create( KLocale::CalendarSystem calendarSystem,
00113                                     const KLocale *locale = 0 );
00114 
00127     static KCalendarSystem *create( KLocale::CalendarSystem calendarSystem, KSharedConfig::Ptr config,
00128                                     const KLocale *locale = 0 );
00129 
00130     //KDE5 remove
00138     static QStringList calendarSystems();
00139 
00147     static QList<KLocale::CalendarSystem> calendarSystemsList();
00148 
00149     //KDE5 remove
00161     static QString calendarLabel( const QString &calendarType );
00162 
00175     static QString calendarLabel( KLocale::CalendarSystem calendarSystem, const KLocale *locale = KGlobal::locale() );
00176 
00186     static KLocale::CalendarSystem calendarSystemForCalendarType( const QString &calendarType );
00187 
00193     explicit KCalendarSystem( const KLocale *locale = 0 );
00194 
00203     explicit KCalendarSystem( const KSharedConfig::Ptr config, const KLocale *locale = 0 );
00204 
00208     virtual ~KCalendarSystem();
00209 
00217     virtual QString calendarType() const = 0;
00218 
00219     //KDE5 make virtual?
00227     KLocale::CalendarSystem calendarSystem() const;
00228 
00229     //KDE5 make virtual?
00237     QString calendarLabel() const;
00238 
00254     virtual QDate epoch() const;
00255 
00266     virtual QDate earliestValidDate() const;
00267 
00276     virtual QDate latestValidDate() const;
00277 
00286     virtual bool isValid( int year, int month, int day ) const = 0;
00287 
00288     //KDE5 make virtual?
00298     bool isValid( int year, int dayOfYear ) const;
00299 
00300     //KDE5 make virtual?
00312     bool isValid( const QString &eraName, int yearInEra, int month, int day ) const;
00313 
00314     //KDE5 make virtual?
00325     bool isValidIsoWeekDate( int year, int isoWeekNumber, int dayOfIsoWeek ) const;
00326 
00333     virtual bool isValid( const QDate &date ) const;
00334 
00347     virtual bool setDate( QDate &date, int year, int month, int day ) const;
00348 
00349     //KDE5 make virtual?
00360     bool setDate( QDate &date, int year, int dayOfYear ) const;
00361 
00362     //KDE5 make virtual?
00375     bool setDate( QDate &date, QString eraName, int yearInEra, int month, int day ) const;
00376 
00377     //KDE5 make virtual?
00389     bool setDateIsoWeek( QDate &date, int year, int isoWeekNumber, int dayOfIsoWeek ) const;
00390 
00411     virtual bool setYMD( QDate &date, int y, int m, int d ) const;
00412 
00413     //KDE5 make virtual?
00424     void getDate( const QDate date, int *year, int *month, int *day ) const;
00425 
00432     virtual int year( const QDate &date ) const;
00433 
00440     virtual int month( const QDate &date ) const;
00441 
00448     virtual int day( const QDate &date ) const;
00449 
00450     //KDE5 make virtual?
00461     QString eraName( const QDate &date, StringFormat format = ShortFormat ) const;
00462 
00463     //KDE5 make virtual?
00474     QString eraYear( const QDate &date, StringFormat format = ShortFormat ) const;
00475 
00476     //KDE5 make virtual?
00486     int yearInEra( const QDate &date ) const;
00487 
00495     virtual QDate addYears( const QDate &date, int nyears ) const;
00496 
00504     virtual QDate addMonths( const QDate &date, int nmonths ) const;
00505 
00513     virtual QDate addDays( const QDate &date, int ndays ) const;
00514 
00515     //KDE5 make virtual?
00534     void dateDifference( const QDate &fromDate, const QDate &toDate,
00535                          int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction ) const;
00536 
00537     //KDE5 make virtual?
00548     int yearsDifference( const QDate &fromDate, const QDate &toDate ) const;
00549 
00550     //KDE5 make virtual?
00563     int monthsDifference( const QDate &fromDate, const QDate &toDate ) const;
00564 
00565     //KDE5 make virtual?
00574     int daysDifference( const QDate &fromDate, const QDate &toDate ) const;
00575 
00582     virtual int monthsInYear( const QDate &date ) const;
00583 
00584     //KDE5 make virtual?
00593     int monthsInYear( int year ) const;
00594 
00601     virtual int weeksInYear( const QDate &date ) const;
00602 
00612     virtual int weeksInYear( int year ) const;
00613 
00620     virtual int daysInYear( const QDate &date ) const;
00621 
00622     //KDE5 make virtual?
00631     int daysInYear( int year ) const;
00632 
00639     virtual int daysInMonth( const QDate &date ) const;
00640 
00641     //KDE5 make virtual?
00651     int daysInMonth( int year, int month ) const;
00652 
00659     virtual int daysInWeek( const QDate &date ) const;
00660 
00669     virtual int dayOfYear( const QDate &date ) const;
00670 
00681     virtual int dayOfWeek( const QDate &date ) const;
00682 
00696     virtual int weekNumber( const QDate &date, int *yearNum = 0 ) const;
00697 
00707     virtual bool isLeapYear( int year ) const = 0;
00708 
00718     virtual bool isLeapYear( const QDate &date ) const;
00719 
00720     //KDE5 Make virtual?
00729     QDate firstDayOfYear( int year ) const;
00730 
00731     //KDE5 Make virtual?
00740     QDate lastDayOfYear( int year ) const;
00741 
00742     //KDE5 Make virtual?
00751     QDate firstDayOfYear( const QDate &date = QDate::currentDate() ) const;
00752 
00753     //KDE5 Make virtual?
00762     QDate lastDayOfYear( const QDate &date = QDate::currentDate() ) const;
00763 
00764     //KDE5 Make virtual?
00773     QDate firstDayOfMonth( int year, int month ) const;
00774 
00775     //KDE5 Make virtual?
00784     QDate lastDayOfMonth( int year, int month ) const;
00785 
00786     //KDE5 Make virtual?
00795     QDate firstDayOfMonth( const QDate &date = QDate::currentDate() ) const;
00796 
00797     //KDE5 Make virtual?
00806     QDate lastDayOfMonth( const QDate &date = QDate::currentDate() ) const;
00807 
00817     virtual QString monthName( int month, int year, MonthNameFormat format = LongName ) const = 0;
00818 
00826     virtual QString monthName( const QDate &date, MonthNameFormat format = LongName ) const;
00827 
00836     virtual QString weekDayName( int weekDay, WeekDayNameFormat format = LongDayName ) const = 0;
00837 
00845     virtual QString weekDayName( const QDate &date, WeekDayNameFormat format = LongDayName ) const;
00846 
00855     virtual QString yearString( const QDate &date, StringFormat format = LongFormat ) const;
00856 
00865     virtual QString monthString( const QDate &pDate, StringFormat format = LongFormat ) const;
00866 
00875     virtual QString dayString( const QDate &pDate, StringFormat format = LongFormat ) const;
00876 
00877     //KDE5 make virtual?
00887     QString yearInEraString( const QDate &date, StringFormat format = ShortFormat ) const;
00888 
00889     //KDE5 make virtual?
00900     QString dayOfYearString( const QDate &pDate, StringFormat format = LongFormat ) const;
00901 
00902     //KDE5 make virtual?
00912     QString dayOfWeekString( const QDate &pDate ) const;
00913 
00914     //KDE5 make virtual?
00925     QString weekNumberString( const QDate &pDate, StringFormat format = LongFormat ) const;
00926 
00927     //KDE5 make virtual?
00938     QString monthsInYearString( const QDate &pDate, StringFormat format = LongFormat ) const;
00939 
00940     //KDE5 make virtual?
00951     QString weeksInYearString( const QDate &pDate, StringFormat format = LongFormat ) const;
00952 
00953     //KDE5 make virtual?
00964     QString daysInYearString( const QDate &pDate, StringFormat format = LongFormat ) const;
00965 
00966     //KDE5 make virtual?
00977     QString daysInMonthString( const QDate &pDate, StringFormat format = LongFormat ) const;
00978 
00979     //KDE5 make virtual?
00989     QString daysInWeekString( const QDate &date ) const;
00990 
00991     //KDE5 make protected or remove?
01001     virtual int yearStringToInteger( const QString &sNum, int &iLength ) const;
01002 
01003     //KDE5 make protected or remove?
01013     virtual int monthStringToInteger( const QString &sNum, int &iLength ) const;
01014 
01015     //KDE5 make protected or remove?
01025     virtual int dayStringToInteger( const QString &sNum, int &iLength ) const;
01026 
01043     virtual QString formatDate( const QDate &fromDate, KLocale::DateFormat toFormat = KLocale::LongDate ) const;
01044 
01045     //KDE5 Make virtual
01162     QString formatDate( const QDate &fromDate, const QString &toFormat,
01163                         KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat ) const;
01164 
01165     //KDE5 Make virtual
01182     QString formatDate( const QDate &fromDate, const QString &toFormat, KLocale::DigitSet digitSet,
01183                         KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat ) const;
01184 
01185     //KDE5 Make virtual
01204     QString formatDate(const QDate &date, KLocale::DateTimeComponent component,
01205                        KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat,
01206                        KLocale::WeekNumberSystem weekNumberSystem = KLocale::DefaultWeekNumber) const;
01207 
01224     virtual QDate readDate( const QString &str, bool *ok = 0 ) const;
01225 
01244     virtual QDate readDate( const QString &str, KLocale::ReadDateFlags flags, bool *ok = 0 ) const;
01245 
01259     virtual QDate readDate( const QString &dateString, const QString &dateFormat, bool *ok = 0 ) const;
01260 
01261     //KDE5 Make virtual
01321     QDate readDate( const QString &dateString, const QString &dateFormat, bool *ok,
01322                     KLocale::DateTimeFormatStandard formatStandard ) const;
01323 
01324     //KDE5 Make virtual
01354     int shortYearWindowStartYear() const;
01355 
01356     //KDE5 Make virtual
01373     int applyShortYearWindow( int inputYear ) const;
01374 
01387     virtual int weekStartDay() const;
01388 
01398     virtual int weekDayOfPray() const = 0;
01399 
01405     virtual bool isLunar() const = 0;
01406 
01412     virtual bool isLunisolar() const = 0;
01413 
01419     virtual bool isSolar() const = 0;
01420 
01429     virtual bool isProleptic() const = 0;
01430 
01431 protected:
01432 
01449     virtual bool julianDayToDate( int jd, int &year, int &month, int &day ) const = 0;
01450 
01467     virtual bool dateToJulianDay( int year, int month, int day, int &jd ) const = 0;
01468 
01491     const KLocale *locale() const;
01492 
01500     void setMaxMonthsInYear( int maxMonths );
01501 
01509     void setMaxDaysInWeek( int maxDays );
01510 
01520     void setHasYear0( bool hasYear0 );
01521 
01531     KCalendarSystem( KCalendarSystemPrivate &dd,
01532                      const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
01533                      const KLocale *locale = 0 );
01534 
01535 private:
01536     //Required for shared d-pointer as already private, remove in KDE5
01537     friend class KCalendarSystemCoptic;
01538     friend class KCalendarSystemEthiopian;
01539     friend class KCalendarSystemGregorian;
01540     friend class KCalendarSystemGregorianProleptic;
01541     friend class KCalendarSystemHebrew;
01542     friend class KCalendarSystemHijri;
01543     friend class KCalendarSystemIndianNational;
01544     friend class KCalendarSystemJalali;
01545     friend class KCalendarSystemJapanese;
01546     friend class KCalendarSystemJulian;
01547     friend class KCalendarSystemMinguo;
01548     friend class KCalendarSystemThai;
01549     friend class KLocalizedDate;
01550     friend class KLocalizedDatePrivate;
01551     friend class KDateTimeParser;
01552 
01553     // Era functions needed by friends, may be made public later if needed in KCM
01554     QList<KCalendarEra> *eraList() const;
01555     KCalendarEra era( const QDate &eraDate ) const;
01556     KCalendarEra era( const QString &eraName, int yearInEra ) const;
01557 
01558     Q_DISABLE_COPY( KCalendarSystem )
01559     KCalendarSystemPrivate * const d_ptr; // KDE5 make protected
01560     Q_DECLARE_PRIVATE( KCalendarSystem )
01561 };
01562 
01563 #endif

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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.3
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