2012-01-31 12:28:12 +01:00
|
|
|
/*
|
2012-02-01 11:09:15 +01:00
|
|
|
Copyright (C) 2012 Giorgos Tsiapaliwkas <terietor@gmail.com>
|
|
|
|
Copyright (C) 2012 Antonis Tsiapaliokas <kok3rs@gmail.com>
|
2012-01-31 12:28:12 +01:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library 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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
#include "calendarsystem.h"
|
2012-01-31 12:28:12 +01:00
|
|
|
|
|
|
|
#include "kdebug.h"
|
|
|
|
#include "kconfiggroup.h"
|
|
|
|
|
|
|
|
#include <QtCore/QDateTime>
|
|
|
|
|
|
|
|
#include "kdatetime.h"
|
|
|
|
#include "kdatetimeformatter_p.h"
|
|
|
|
#include "kdatetimeparser_p.h"
|
|
|
|
#include "kcalendarera_p.h"
|
|
|
|
#include "kcalendarsystemcoptic_p.h"
|
|
|
|
#include "kcalendarsystemethiopian_p.h"
|
|
|
|
#include "kcalendarsystemgregorian_p.h"
|
|
|
|
#include "kcalendarsystemhebrew_p.h"
|
|
|
|
#include "kcalendarsystemindiannational_p.h"
|
|
|
|
#include "kcalendarsystemislamiccivil_p.h"
|
|
|
|
#include "kcalendarsystemjalali_p.h"
|
|
|
|
#include "kcalendarsystemjapanese_p.h"
|
|
|
|
#include "kcalendarsystemjulian_p.h"
|
|
|
|
#include "kcalendarsystemminguo_p.h"
|
|
|
|
#include "kcalendarsystemqdate_p.h"
|
|
|
|
#include "kcalendarsystemthai_p.h"
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
//FIXME fix all the create static methods
|
2012-02-01 10:47:40 +01:00
|
|
|
KCalendarSystem *CalendarSystem::create(const QString &calendarType, const KLocale *locale)
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
|
|
|
return create(calendarSystem(calendarType), locale);
|
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
KCalendarSystem *CalendarSystem::create(const QString &calendarType, KSharedConfig::Ptr config,
|
2012-01-31 12:28:12 +01:00
|
|
|
const KLocale *locale)
|
|
|
|
{
|
|
|
|
return create(calendarSystem(calendarType), config, locale);
|
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::calendarLabel(const QString &calendarType)
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 11:24:48 +01:00
|
|
|
return m_calendarSystem->calendarLabel(calendarType);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
KCalendarSystem *CalendarSystem::create(Locale::CalendarSystem calendarSystem, const KLocale *locale)
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
|
|
|
return create(calendarSystem, KSharedConfig::Ptr(), locale);
|
|
|
|
}
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
KCalendarSystem *CalendarSystem::create(Locale::CalendarSystem calendarSystem,
|
2012-01-31 12:28:12 +01:00
|
|
|
KSharedConfig::Ptr config,
|
|
|
|
const KLocale *locale)
|
|
|
|
{
|
|
|
|
switch (calendarSystem) {
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::QDateCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemQDate(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::CopticCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemCoptic(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::EthiopianCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemEthiopian(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::GregorianCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemGregorian(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::HebrewCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemHebrew(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::IndianNationalCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemIndianNational(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::IslamicCivilCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemIslamicCivil(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::JalaliCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemJalali(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::JapaneseCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemJapanese(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::JulianCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemJulian(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::MinguoCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemMinguo(config, locale);
|
2012-02-01 11:24:48 +01:00
|
|
|
case Locale::ThaiCalendar:
|
2012-01-31 12:28:12 +01:00
|
|
|
return new KCalendarSystemThai(config, locale);
|
|
|
|
default:
|
|
|
|
return new KCalendarSystemQDate(config, locale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
QList<Locale::CalendarSystem> CalendarSystem::calendarSystemsList()
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
QList<Locale::CalendarSystem> list;
|
2012-01-31 12:28:12 +01:00
|
|
|
|
2012-02-01 13:02:43 +01:00
|
|
|
foreach(KLocale::CalendarSystem calendarSystem, m_calendarSystem->calendarSystemList()) {
|
|
|
|
list.append((Locale::CalendarSystem)calendarSystem);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 13:02:43 +01:00
|
|
|
return list;
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 13:02:43 +01:00
|
|
|
QString CalendarSystem::calendarLabel(Locale::CalendarSystem calendarSystem, const Locale *locale)
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->calendarLabel((KLocale::CalendarSystem)calendarSystem, (KLocale)locale);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
Locale::CalendarSystem CalendarSystem::calendarSystem(const QString &calendarType )
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return (Locale::CalendarSystem)m_calendarSystem->calendarSystem(calendarType);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 11:24:48 +01:00
|
|
|
Locale::CalendarSystem CalendarSystem::calendarSystem() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return (Locale::CalendarSystem)m_calendarSystem->calendarSystem();
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::calendarLabel() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 10:47:40 +01:00
|
|
|
return CalendarSystem::calendarLabel(calendarSystem());
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dummy version using Gregorian as an example
|
|
|
|
// This method MUST be re-implemented in any new Calendar System
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::epoch() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->epoch();
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::earliestValidDate() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
|
|
|
return epoch();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dummy version using Gregorian as an example
|
|
|
|
// This method MUST be re-implemented in any new Calendar System
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::latestValidDate() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
|
|
|
// Default to Gregorian 9999-12-31
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->latestValidDate();
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::isValid(int year, int month, int day) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->isValid(year, month, day);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::isValid(int year, int dayOfYear) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->isValid(year, dayOfYear);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::isValid(const QString &eraName, int yearInEra, int month, int day) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->isValid(eraName, yearInEra, month, day);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::isValidIsoWeekDate(int year, int isoWeekNumber, int dayOfIsoWeek) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->isValidIsoWeekDate(year, isoWeekNumber, dayOfIsoWeek);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::isValid(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->isValid(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::setDate(QDate &date, int year, int month, int day) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->setDate(date, year, month, day);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::setDate(QDate &date, int year, int dayOfYear) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->setDate(date, year, dayOfYear);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::setDate(QDate &date, QString eraName, int yearInEra, int month, int day) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->setDate(date, eraName, yearInEra, month, day);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::setDateIsoWeek(QDate &date, int year, int isoWeekNumber, int dayOfIsoWeek) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
m_calendarSystem->setDateIsoWeek(date, year, isoWeekNumber, dayOfIsoWeek);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
void CalendarSystem::getDate(const QDate date, int *year, int *month, int *day) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->getDate(date, year, month, day);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::year(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->year(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::month(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->month(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::day(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->day(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::eraName(const QDate &date, StringFormat format) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->eraName(date, format);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::eraYear(const QDate &date, StringFormat format) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->eraYear(date, format);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::yearInEra(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->yearInEra(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 13:02:43 +01:00
|
|
|
//FIXME we need a wrapper for KCalendarEra!!
|
|
|
|
/*QList<KCalendarEra> *CalendarSystem::eraList() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
|
|
|
Q_D(const KCalendarSystem);
|
|
|
|
|
|
|
|
return d->eraList();
|
2012-02-01 13:02:43 +01:00
|
|
|
}*/
|
2012-01-31 12:28:12 +01:00
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 13:02:43 +01:00
|
|
|
/*FIXME we don't need the above.Correct?
|
2012-02-01 10:47:40 +01:00
|
|
|
KCalendarEra CalendarSystem::era(const QDate &eraDate) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
|
|
|
Q_D(const KCalendarSystem);
|
|
|
|
|
|
|
|
return d->era(eraDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
KCalendarEra CalendarSystem::era(const QString &eraName, int yearInEra) const
|
2012-02-01 13:02:43 +01:00
|
|
|
{
|
|
|
|
Q_D(const KCalendarSystem);
|
2012-01-31 12:28:12 +01:00
|
|
|
|
2012-02-01 13:02:43 +01:00
|
|
|
return d->era(eraName, yearInEra);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
QDate CalendarSystem::addYears(const QDate &date, int numYears) const
|
|
|
|
{
|
|
|
|
return m_calendarSystem->addYears(date, numYears);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::addMonths(const QDate &date, int numMonths) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->addMonths(date, numMonths);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::addDays(const QDate &date, int numDays) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->addDays(date, numDays);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
void CalendarSystem::dateDifference(const QDate &fromDate, const QDate &toDate,
|
2012-01-31 12:28:12 +01:00
|
|
|
int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const
|
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->dateDifference(fromDate, toDate, yearsDiff, monthsDiff, daysDiff, direction);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::yearsDifference(const QDate &fromDate, const QDate &toDate) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->yearsDifference(fromDate, toDate);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::monthsDifference(const QDate &fromDate, const QDate &toDate) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->monthsDifference(fromDate, toDate);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::daysDifference(const QDate &fromDate, const QDate &toDate) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->daysDifference(fromDate, toDate);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::monthsInYear(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->monthsInYear(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::monthsInYear(int year) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->monthsInYear(year);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::weeksInYear(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 11:24:48 +01:00
|
|
|
return weeksInYear(date, Locale::DefaultWeekNumber);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::weeksInYear(int year) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 11:24:48 +01:00
|
|
|
return weeksInYear(year, Locale::DefaultWeekNumber);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 11:24:48 +01:00
|
|
|
int CalendarSystem::weeksInYear(const QDate &date, Locale::WeekNumberSystem weekNumberSystem) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->weeksInYear(date, (KLocale::WeekNumberSystem)weekNumberSystem);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 11:24:48 +01:00
|
|
|
int CalendarSystem::weeksInYear(int year, Locale::WeekNumberSystem weekNumberSystem) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->weeksInYear(year, (KLocale::WeekNumberSystem)weekNumberSystem);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::daysInYear(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->daysInYear(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::daysInYear(int year) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->daysInYear(year);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::daysInMonth(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->daysInMonth(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::daysInMonth(int year, int month) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->daysInMonth(year, month);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::daysInWeek(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->daysInWeek();
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::dayOfYear(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->dayOfYear(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::dayOfWeek(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->dayOfWeek(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::weekNumber(const QDate &date, int *yearNum) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 11:24:48 +01:00
|
|
|
return week(date, Locale::IsoWeekNumber, yearNum);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::week(const QDate &date, int *yearNum) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 11:24:48 +01:00
|
|
|
return week(date, Locale::DefaultWeekNumber, yearNum);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - Uses shared-d instead
|
2012-02-01 11:24:48 +01:00
|
|
|
int CalendarSystem::week(const QDate &date, Locale::WeekNumberSystem weekNumberSystem, int *yearNum) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->week(date, (KLocale::WeekNumberSystem)weekNumberSystem, yearNum);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::isLeapYear(int year) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->isLeapYear(year);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::isLeapYear(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->isLeapYear(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::firstDayOfYear(int year) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->firstDayOfYear(year);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::lastDayOfYear(int year) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->lastDayOfYear(year);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::firstDayOfYear(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->firstDayOfYear(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::lastDayOfYear(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->lastDayOfYear(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::firstDayOfMonth(int year, int month) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->firstDayOfMonth(year, month);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::lastDayOfMonth(int year, int month) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->lastDayOfMonth(year, month);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::firstDayOfMonth(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->firstDayOfMonth(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::lastDayOfMonth(const QDate &date) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->lastDayOfMonth(date);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::monthName(int month, int year, CalendarSystem::MonthNameFormat format) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->monthName(month, year, (KCalendarSystem::MonthNameFormat)format);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::monthName(const QDate &date, MonthNameFormat format) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->monthName(date, (KCalendarSystem::MonthNameFormat)format);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::weekDayName(int weekDay, CalendarSystem::WeekDayNameFormat format) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->weekDayName(weekDay, (KCalendarSystem::WeekDayNameFormat)format);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->weekDayName(date, (KCalendarSystem::WeekDayNameFormat)format);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
QString CalendarSystem::formatDate(const QDate &fromDate, Locale::DateFormat toFormat) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->formatDate(fromDate, (KLocale::DateFormat)toFormat);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QString CalendarSystem::formatDate(const QDate &fromDate, const QString &toFormat,
|
2012-02-01 11:24:48 +01:00
|
|
|
Locale::DateTimeFormatStandard standard) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->formatDate(fromDate, toFormat, (KLocale::DateTimeFormatStandard)standar);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 11:24:48 +01:00
|
|
|
QString CalendarSystem::formatDate(const QDate &fromDate, const QString &toFormat, Locale::DigitSet digitSet,
|
|
|
|
Locale::DateTimeFormatStandard formatStandard) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->formatDate(fromDate, toFormat, (KLocale::DigitSet)digitSet,
|
|
|
|
(KLocale::DateTimeFormatStandard)formatStandard);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 11:24:48 +01:00
|
|
|
QString CalendarSystem::formatDate(const QDate &date, Locale::DateTimeComponent component,
|
|
|
|
Locale::DateTimeComponentFormat format,
|
|
|
|
Locale::WeekNumberSystem weekNumberSystem) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->formatDate(date, (KLocale::DateTimeComponent)component,
|
|
|
|
(KLocale::DateTimeComponentFormat)format,
|
|
|
|
(KLocale::WeekNumberSystem)weekNumberSystem);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::readDate(const QString &str, bool *ok) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->readDate(str, ok);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 11:24:48 +01:00
|
|
|
QDate CalendarSystem::readDate(const QString &str, Locale::ReadDateFlags flags, bool *ok) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->readDate(str, (KLocale::ReadDateFlags)flags, ok);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::readDate(const QString &inputString, const QString &formatString, bool *ok) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 11:24:48 +01:00
|
|
|
return readDate(inputString, formatString, ok, Locale::KdeFormat);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
QDate CalendarSystem::readDate(const QString &inputString, const QString &formatString, bool *ok,
|
2012-02-01 11:24:48 +01:00
|
|
|
Locale::DateTimeFormatStandard formatStandard) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->readDate(inputString, formatString, ok,
|
|
|
|
(KLocale::DateTimeFormatStandard)formatStandard);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::shortYearWindowStartYear() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->shortYearWindowStartYear();
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOT VIRTUAL - If override needed use shared-d
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::applyShortYearWindow(int inputYear) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->applyShortYearWindow(inputYear);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 10:47:40 +01:00
|
|
|
int CalendarSystem::weekStartDay() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->weekStartDay();
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dummy version using Gregorian as an example
|
|
|
|
// This method MUST be re-implemented in any new Calendar System
|
|
|
|
// The implementation MUST NOT do validity checking on date ranges, all calls to this function MUST
|
|
|
|
// instead be wrapped in validity checks, as sometimes we want this to work outside the public valid
|
|
|
|
// range, i.e. to allow us to internally set dates of 1/1/10000 which are not publically valid but
|
|
|
|
// are required for internal maths
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::julianDayToDate(int jd, int &year, int &month, int &day) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->julianDayToDate(jd, year, month, day);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dummy version using Gregorian as an example
|
|
|
|
// This method MUST be re-implemented in any new Calendar System
|
|
|
|
// The implementation MUST NOT do validity checking on date ranges, all calls to this function MUST
|
|
|
|
// instead be wrapped in validity checks, as sometimes we want this to work outside the public valid
|
|
|
|
// range, i.e. to allow us to internally set dates of 1/1/10000 which are not publically valid but
|
|
|
|
// are required for internal maths
|
2012-02-01 10:47:40 +01:00
|
|
|
bool CalendarSystem::dateToJulianDay(int year, int month, int day, int &jd) const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
2012-02-01 13:02:43 +01:00
|
|
|
return m_calendarSystem->dateToJulianDay(year, month, day, jd);
|
2012-01-31 12:28:12 +01:00
|
|
|
}
|
|
|
|
|
2012-02-01 13:02:43 +01:00
|
|
|
//FIXME what should I do with the above one?
|
|
|
|
/*const KLocale * CalendarSystem::locale() const
|
2012-01-31 12:28:12 +01:00
|
|
|
{
|
|
|
|
Q_D(const KCalendarSystem);
|
|
|
|
|
|
|
|
return d->locale();
|
2012-02-01 13:02:43 +01:00
|
|
|
}*/
|