mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-24 10:52:52 +00:00
186 lines
12 KiB
Text
186 lines
12 KiB
Text
//
|
|
// Copyright 2008 Jim Bublitz <jbublitz@nwinternet.com>
|
|
// Earlier copyrights 1998 - 2007 Jim Bublitz also apply
|
|
|
|
// Generated by twine
|
|
|
|
// This file is part of PyKDE4.
|
|
|
|
// PyKDE4 is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
// published by the Free Software Foundation; either version 2.1 of
|
|
// the License, or (at your option) any later version.
|
|
|
|
// PyKDE4 is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
class KCalendarSystem
|
|
{
|
|
%TypeHeaderCode
|
|
#include <kcalendarsystem.h>
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
enum StringFormat
|
|
{
|
|
ShortFormat,
|
|
LongFormat
|
|
};
|
|
|
|
|
|
enum MonthNameFormat
|
|
{
|
|
ShortName,
|
|
LongName,
|
|
ShortNamePossessive,
|
|
LongNamePossessive,
|
|
NarrowName
|
|
};
|
|
|
|
|
|
enum WeekDayNameFormat
|
|
{
|
|
ShortDayName,
|
|
LongDayName,
|
|
NarrowDayName
|
|
};
|
|
|
|
static KCalendarSystem* create (const QString& calType = QLatin1String("gregorian"), const KLocale* locale = 0);
|
|
static QStringList calendarSystems ();
|
|
static QString calendarLabel (const QString& calendarType);
|
|
explicit KCalendarSystem (const KLocale* locale = 0);
|
|
virtual QString calendarType () const=0;
|
|
virtual QDate epoch () const;
|
|
virtual QDate earliestValidDate () const;
|
|
virtual QDate latestValidDate () const;
|
|
virtual bool isValid (int year, int month, int day) const=0;
|
|
virtual bool isValid (const QDate& date) const;
|
|
virtual bool setDate (QDate& date, int year, int month, int day) const;
|
|
virtual bool setYMD (QDate& date, int y, int m, int d) const;
|
|
virtual int year (const QDate& date) const;
|
|
virtual int month (const QDate& date) const;
|
|
virtual int day (const QDate& date) const;
|
|
virtual QDate addYears (const QDate& date, int nyears) const;
|
|
virtual QDate addMonths (const QDate& date, int nmonths) const;
|
|
virtual QDate addDays (const QDate& date, int ndays) const;
|
|
virtual int monthsInYear (const QDate& date) const;
|
|
virtual int weeksInYear (const QDate& date) const;
|
|
virtual int weeksInYear (int year) const;
|
|
virtual int daysInYear (const QDate& date) const;
|
|
virtual int daysInMonth (const QDate& date) const;
|
|
virtual int daysInWeek (const QDate& date) const;
|
|
virtual int dayOfYear (const QDate& date) const;
|
|
virtual int dayOfWeek (const QDate& date) const;
|
|
virtual int weekNumber (const QDate& date, int* yearNum /In,Out/ = 0) const;
|
|
virtual bool isLeapYear (int year) const=0;
|
|
virtual bool isLeapYear (const QDate& date) const;
|
|
virtual QString monthName (int month, int year, KCalendarSystem::MonthNameFormat format = KCalendarSystem::LongName) const=0;
|
|
virtual QString monthName (const QDate& date, KCalendarSystem::MonthNameFormat format = KCalendarSystem::LongName) const;
|
|
virtual QString weekDayName (int weekDay, KCalendarSystem::WeekDayNameFormat format = KCalendarSystem::LongDayName) const=0;
|
|
virtual QString weekDayName (const QDate& date, KCalendarSystem::WeekDayNameFormat format = KCalendarSystem::LongDayName) const;
|
|
virtual QString yearString (const QDate& date, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
virtual QString monthString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
virtual QString dayString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
virtual int yearStringToInteger (const QString& sNum, int& iLength /Out/) const;
|
|
virtual int monthStringToInteger (const QString& sNum, int& iLength /Out/) const;
|
|
virtual int dayStringToInteger (const QString& sNum, int& iLength /Out/) const;
|
|
virtual QString formatDate (const QDate& fromDate, KLocale::DateFormat toFormat = KLocale::LongDate) const;
|
|
virtual QDate readDate (const QString& str, bool* ok /Out/ = 0) const;
|
|
virtual QDate readDate (const QString& dateString, const QString& dateFormat, bool* ok /Out/ = 0) const;
|
|
virtual QDate readDate (const QString& str, KLocale::ReadDateFlags flags, bool* ok /Out/ = 0) const;
|
|
virtual int weekStartDay () const;
|
|
virtual int weekDayOfPray () const=0;
|
|
virtual bool isLunar () const=0;
|
|
virtual bool isLunisolar () const=0;
|
|
virtual bool isSolar () const=0;
|
|
virtual bool isProleptic () const=0;
|
|
|
|
protected:
|
|
virtual bool julianDayToDate (int jd, int& year /Out/, int& month /Out/, int& day /Out/) const=0;
|
|
virtual bool dateToJulianDay (int year, int month, int day, int& jd /Out/) const=0;
|
|
const KLocale* locale () const;
|
|
|
|
private:
|
|
//force
|
|
KCalendarSystem (const KCalendarSystem&);
|
|
//end
|
|
public:
|
|
~KCalendarSystem ();
|
|
QString formatDate (const QDate& fromDate, const QString& toFormat, KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
|
|
protected:
|
|
void setMaxMonthsInYear (int maxMonths);
|
|
void setMaxDaysInWeek (int maxDays);
|
|
void setHasYear0 (bool hasYear0);
|
|
public:
|
|
bool isValid (int year, int dayOfYear) const;
|
|
bool isValidIsoWeekDate (int year, int isoWeekNumber, int dayOfIsoWeek) const;
|
|
bool setDate (QDate& date, int year, int dayOfYear) const;
|
|
bool setDateIsoWeek (QDate& date, int year, int isoWeekNumber, int dayOfIsoWeek) const;
|
|
QString dayOfYearString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
QString dayOfWeekString (const QDate& pDate) const;
|
|
QString weekNumberString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
QString monthsInYearString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
QString weeksInYearString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
QString daysInYearString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
QString daysInMonthString (const QDate& pDate, KCalendarSystem::StringFormat format = KCalendarSystem::LongFormat) const;
|
|
QString daysInWeekString (const QDate& date) const;
|
|
QString formatDate (const QDate& fromDate, const QString& toFormat, KLocale::DigitSet digitSet, KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
|
|
static KCalendarSystem* create (const QString& calType, KSharedConfig::Ptr config, const KLocale* locale = 0);
|
|
explicit KCalendarSystem (const KSharedConfig::Ptr config, const KLocale* locale = 0);
|
|
bool isValid (const QString& eraName, int yearInEra, int month, int day) const;
|
|
bool setDate (QDate& date, QString eraName, int yearInEra, int month, int day) const;
|
|
void getDate (const QDate date, int* year, int* month, int* day) const;
|
|
QString eraName (const QDate& date, KCalendarSystem::StringFormat format = KCalendarSystem::ShortFormat) const;
|
|
QString eraYear (const QDate& date, KCalendarSystem::StringFormat format = KCalendarSystem::ShortFormat) const;
|
|
int yearInEra (const QDate& date) const;
|
|
void dateDifference (const QDate& fromDate, const QDate& toDate, int* yearsDiff, int* monthsDiff, int* daysDiff, int* direction) const;
|
|
int yearsDifference (const QDate& fromDate, const QDate& toDate) const;
|
|
int monthsDifference (const QDate& fromDate, const QDate& toDate) const;
|
|
int daysDifference (const QDate& fromDate, const QDate& toDate) const;
|
|
int monthsInYear (int year) const;
|
|
int daysInYear (int year) const;
|
|
int daysInMonth (int year, int month) const;
|
|
QString yearInEraString (const QDate& date, KCalendarSystem::StringFormat format = KCalendarSystem::ShortFormat) const;
|
|
QDate readDate (const QString& dateString, const QString& dateFormat, bool* ok, KLocale::DateTimeFormatStandard formatStandard) const;
|
|
protected:
|
|
//ig KCalendarSystem (KCalendarSystemPrivate& dd, const KSharedConfig::Ptr config = KSharedConfig::Ptr(), const KLocale* locale = 0);
|
|
public:
|
|
static KCalendarSystem* create (KLocale::CalendarSystem calendarSystem, const KLocale* locale = 0);
|
|
static KCalendarSystem* create (KLocale::CalendarSystem calendarSystem, KSharedConfig::Ptr config, const KLocale* locale = 0);
|
|
static QList<KLocale::CalendarSystem> calendarSystemsList ();
|
|
static QString calendarLabel (KLocale::CalendarSystem calendarSystem, const KLocale* locale = KGlobal::locale());
|
|
KLocale::CalendarSystem calendarSystem () const;
|
|
QString calendarLabel () const;
|
|
QDate firstDayOfYear (int year) const;
|
|
QDate lastDayOfYear (int year) const;
|
|
QDate firstDayOfYear (const QDate& date = QDate::currentDate()) const;
|
|
QDate lastDayOfYear (const QDate& date = QDate::currentDate()) const;
|
|
QDate firstDayOfMonth (int year, int month) const;
|
|
QDate lastDayOfMonth (int year, int month) const;
|
|
QDate firstDayOfMonth (const QDate& date = QDate::currentDate()) const;
|
|
QDate lastDayOfMonth (const QDate& date = QDate::currentDate()) const;
|
|
int shortYearWindowStartYear () const;
|
|
int applyShortYearWindow (int inputYear) const;
|
|
static KLocale::CalendarSystem calendarSystemForCalendarType (const QString& calendarType);
|
|
QString formatDate (const QDate& date, KLocale::DateTimeComponent component, KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat, KLocale::WeekNumberSystem weekNumberSystem = KLocale::DefaultWeekNumber) const;
|
|
|
|
// Missing implementation
|
|
//ig int weeksInYear (const QDate& date, KLocale::WeekNumberSystem weekNumberSystem) const;
|
|
|
|
int weeksInYear (int year, KLocale::WeekNumberSystem weekNumberSystem) const;
|
|
int week (const QDate& date, int* yearNum = 0) const;
|
|
int week (const QDate& date, KLocale::WeekNumberSystem weekNumberSystem, int* yearNum = 0) const;
|
|
static KLocale::CalendarSystem calendarSystem (const QString& calendarType);
|
|
static QString calendarType (KLocale::CalendarSystem calendarSystem);
|
|
};
|
|
// KCalendarSystem
|
|
|
|
|