• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • 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 (c) 2007 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 
00028 #include <QtCore/QStringList>
00029 
00030 class KCalendarSystemPrivate;
00031 
00032 class QDate;
00033 
00039 class KDECORE_EXPORT KCalendarSystem
00040 {
00041 public:
00042 
00046     enum StringFormat {
00047          ShortFormat,      
00048          LongFormat        
00049     };
00050 
00054     enum MonthNameFormat {
00055          ShortName,                
00056          LongName,                 
00057          ShortNamePossessive,      
00058          LongNamePossessive        
00059     };
00060 
00064     enum WeekDayNameFormat {
00065          ShortDayName,                
00066          LongDayName                  
00067     };
00068 
00077     static KCalendarSystem *create( const QString & calType = QLatin1String( "gregorian" ),
00078                                      const KLocale * locale = 0 );
00079 
00085     static QStringList calendarSystems();
00086 
00096     static QString calendarLabel( const QString &calendarType );
00097 
00103     explicit KCalendarSystem( const KLocale *locale = 0 );
00104 
00108     virtual ~KCalendarSystem();
00109 
00115     virtual QString calendarType() const = 0;
00116 
00132     virtual QDate epoch() const;
00133 
00144     virtual QDate earliestValidDate() const;
00145 
00154     virtual QDate latestValidDate() const;
00155 
00164     virtual bool isValid( int year, int month, int day ) const = 0;
00165 
00172     virtual bool isValid( const QDate &date ) const;
00173 
00186     virtual bool setDate( QDate &date, int year, int month, int day ) const;
00187 
00208     virtual bool setYMD( QDate &date, int y, int m, int d ) const;
00209 
00216     virtual int year( const QDate &date ) const;
00217 
00224     virtual int month( const QDate &date ) const;
00225 
00232     virtual int day( const QDate &date ) const;
00233 
00241     virtual QDate addYears( const QDate &date, int nyears ) const;
00242 
00250     virtual QDate addMonths( const QDate &date, int nmonths ) const;
00251 
00259     virtual QDate addDays( const QDate &date, int ndays ) const;
00260 
00267     virtual int monthsInYear( const QDate &date ) const;
00268 
00275     virtual int weeksInYear( const QDate &date ) const;
00276 
00286     virtual int weeksInYear( int year ) const;
00287 
00294     virtual int daysInYear( const QDate &date ) const;
00295 
00302     virtual int daysInMonth( const QDate &date ) const;
00303 
00310     virtual int daysInWeek( const QDate &date ) const;
00311 
00318     virtual int dayOfYear( const QDate &date ) const;
00319 
00326     virtual int dayOfWeek( const QDate &date ) const;
00327 
00341     virtual int weekNumber( const QDate &date, int *yearNum = 0 ) const;
00342 
00352     virtual bool isLeapYear( int year ) const = 0;
00353 
00363     virtual bool isLeapYear( const QDate &date ) const;
00364 
00374     virtual QString monthName( int month, int year, MonthNameFormat format = LongName ) const = 0;
00375 
00383     virtual QString monthName( const QDate &date, MonthNameFormat format = LongName ) const;
00384 
00393     virtual QString weekDayName( int weekDay, WeekDayNameFormat format = LongDayName ) const = 0;
00394 
00402     virtual QString weekDayName( const QDate &date, WeekDayNameFormat format = LongDayName ) const;
00403 
00411     virtual QString yearString( const QDate &date, StringFormat format = LongFormat ) const;
00412 
00420     virtual QString monthString( const QDate &pDate, StringFormat format = LongFormat ) const;
00421 
00429     virtual QString dayString( const QDate &pDate, StringFormat format = LongFormat ) const;
00430 
00438     virtual int yearStringToInteger( const QString &sNum, int &iLength ) const;
00439 
00447     virtual int monthStringToInteger( const QString &sNum, int &iLength ) const;
00448 
00456     virtual int dayStringToInteger( const QString &sNum, int &iLength ) const;
00457 
00474     virtual QString formatDate( const QDate &date, KLocale::DateFormat format = KLocale::LongDate ) const;
00475 
00492     virtual QDate readDate( const QString &str, bool *ok = 0 ) const;
00493 
00500     virtual QDate readDate( const QString &intstr, const QString &format, bool *ok = 0 ) const;
00501 
00520     virtual QDate readDate( const QString &str, KLocale::ReadDateFlags flags, bool *ok = 0 ) const;
00521 
00534     virtual int weekStartDay() const;
00535 
00545     virtual int weekDayOfPray() const = 0;
00546 
00552     virtual bool isLunar() const = 0;
00553 
00559     virtual bool isLunisolar() const = 0;
00560 
00566     virtual bool isSolar() const = 0;
00567 
00576     virtual bool isProleptic() const = 0;
00577 
00578 protected:
00579 
00580     friend class KCalendarSystemPrivate;
00581 
00598     virtual bool julianDayToDate( int jd, int &year, int &month, int &day ) const = 0;
00599 
00616     virtual bool dateToJulianDay( int year, int month, int day, int &jd ) const = 0;
00617 
00640     const KLocale *locale() const;
00641 
00642 private:
00643     Q_DISABLE_COPY( KCalendarSystem )
00644     KCalendarSystemPrivate * const d;
00645 };
00646 
00647 #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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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