mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: drop support for all but gregorian and julian calendars
additional calendar systems can be supported via ICU in the future but for now that will be more than enough considering other things such as QDateTime and QCalendarWidget, the gregorian and julian calendars being common, etc. Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ce03856f54
commit
de31c50479
26 changed files with 7 additions and 5463 deletions
|
@ -51,18 +51,9 @@ set(kdecore_LIB_SRCS
|
|||
config/ksettings.cpp
|
||||
date/kcalendarera.cpp
|
||||
date/kcalendarsystem.cpp
|
||||
date/kcalendarsystemcoptic.cpp
|
||||
date/kcalendarsystemethiopian.cpp
|
||||
date/kcalendarsystemqdate.cpp
|
||||
date/kcalendarsystemgregorian.cpp
|
||||
date/kcalendarsystemislamiccivil.cpp
|
||||
date/kcalendarsystemhebrew.cpp
|
||||
date/kcalendarsystemindiannational.cpp
|
||||
date/kcalendarsystemjalali.cpp
|
||||
date/kcalendarsystemjapanese.cpp
|
||||
date/kcalendarsystemjulian.cpp
|
||||
date/kcalendarsystemminguo.cpp
|
||||
date/kcalendarsystemthai.cpp
|
||||
date/kdatetime.cpp
|
||||
date/kdatetimeformatter.cpp
|
||||
date/kdatetimeparser.cpp
|
||||
|
|
|
@ -31,18 +31,9 @@
|
|||
#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"
|
||||
|
||||
KCalendarSystem *KCalendarSystem::create(KLocale::CalendarSystem calendarSystem, const KLocale *locale)
|
||||
{
|
||||
|
@ -56,28 +47,10 @@ KCalendarSystem *KCalendarSystem::create(KLocale::CalendarSystem calendarSystem,
|
|||
switch (calendarSystem) {
|
||||
case KLocale::QDateCalendar:
|
||||
return new KCalendarSystemQDate(config, locale);
|
||||
case KLocale::CopticCalendar:
|
||||
return new KCalendarSystemCoptic(config, locale);
|
||||
case KLocale::EthiopianCalendar:
|
||||
return new KCalendarSystemEthiopian(config, locale);
|
||||
case KLocale::GregorianCalendar:
|
||||
return new KCalendarSystemGregorian(config, locale);
|
||||
case KLocale::HebrewCalendar:
|
||||
return new KCalendarSystemHebrew(config, locale);
|
||||
case KLocale::IndianNationalCalendar:
|
||||
return new KCalendarSystemIndianNational(config, locale);
|
||||
case KLocale::IslamicCivilCalendar:
|
||||
return new KCalendarSystemIslamicCivil(config, locale);
|
||||
case KLocale::JalaliCalendar:
|
||||
return new KCalendarSystemJalali(config, locale);
|
||||
case KLocale::JapaneseCalendar:
|
||||
return new KCalendarSystemJapanese(config, locale);
|
||||
case KLocale::JulianCalendar:
|
||||
return new KCalendarSystemJulian(config, locale);
|
||||
case KLocale::MinguoCalendar:
|
||||
return new KCalendarSystemMinguo(config, locale);
|
||||
case KLocale::ThaiCalendar:
|
||||
return new KCalendarSystemThai(config, locale);
|
||||
default:
|
||||
return new KCalendarSystemQDate(config, locale);
|
||||
}
|
||||
|
@ -88,17 +61,8 @@ QList<KLocale::CalendarSystem> KCalendarSystem::calendarSystemsList()
|
|||
QList<KLocale::CalendarSystem> list;
|
||||
|
||||
list.append(KLocale::QDateCalendar);
|
||||
list.append(KLocale::CopticCalendar);
|
||||
list.append(KLocale::EthiopianCalendar);
|
||||
list.append(KLocale::GregorianCalendar);
|
||||
list.append(KLocale::HebrewCalendar);
|
||||
list.append(KLocale::IslamicCivilCalendar);
|
||||
list.append(KLocale::IndianNationalCalendar);
|
||||
list.append(KLocale::JalaliCalendar);
|
||||
list.append(KLocale::JapaneseCalendar);
|
||||
list.append(KLocale::JulianCalendar);
|
||||
list.append(KLocale::MinguoCalendar);
|
||||
list.append(KLocale::ThaiCalendar);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -108,28 +72,10 @@ QString KCalendarSystem::calendarLabel(KLocale::CalendarSystem calendarSystem, c
|
|||
switch (calendarSystem) {
|
||||
case KLocale::QDateCalendar:
|
||||
return ki18nc("@item Calendar system", "Gregorian").toString(locale);
|
||||
case KLocale::CopticCalendar:
|
||||
return ki18nc("@item Calendar system", "Coptic").toString(locale);
|
||||
case KLocale::EthiopianCalendar:
|
||||
return ki18nc("@item Calendar system", "Ethiopian").toString(locale);
|
||||
case KLocale::GregorianCalendar:
|
||||
return ki18nc("@item Calendar system", "Gregorian (Proleptic)").toString(locale);
|
||||
case KLocale::HebrewCalendar:
|
||||
return ki18nc("@item Calendar system", "Hebrew").toString(locale);
|
||||
case KLocale::IslamicCivilCalendar:
|
||||
return ki18nc("@item Calendar system", "Islamic / Hijri (Civil)").toString(locale);
|
||||
case KLocale::IndianNationalCalendar:
|
||||
return ki18nc("@item Calendar system", "Indian National").toString(locale);
|
||||
case KLocale::JalaliCalendar:
|
||||
return ki18nc("@item Calendar system", "Jalali").toString(locale);
|
||||
case KLocale::JapaneseCalendar:
|
||||
return ki18nc("@item Calendar system", "Japanese").toString(locale);
|
||||
case KLocale::JulianCalendar:
|
||||
return ki18nc("@item Calendar system", "Julian").toString(locale);
|
||||
case KLocale::MinguoCalendar:
|
||||
return ki18nc("@item Calendar system", "Taiwanese").toString(locale);
|
||||
case KLocale::ThaiCalendar:
|
||||
return ki18nc("@item Calendar system", "Thai").toString(locale);
|
||||
}
|
||||
|
||||
return ki18nc("@item Calendar system", "Invalid Calendar Type").toString(locale);
|
||||
|
@ -137,30 +83,12 @@ QString KCalendarSystem::calendarLabel(KLocale::CalendarSystem calendarSystem, c
|
|||
|
||||
KLocale::CalendarSystem KCalendarSystem::calendarSystem(const QString &calendarType )
|
||||
{
|
||||
if (calendarType == QLatin1String("coptic")) {
|
||||
return KLocale::CopticCalendar;
|
||||
} else if (calendarType == QLatin1String("ethiopian")) {
|
||||
return KLocale::EthiopianCalendar;
|
||||
} else if (calendarType == QLatin1String("gregorian")) {
|
||||
if (calendarType == QLatin1String("gregorian")) {
|
||||
return KLocale::QDateCalendar;
|
||||
} else if (calendarType == QLatin1String("gregorian-proleptic")) {
|
||||
return KLocale::GregorianCalendar;
|
||||
} else if (calendarType == QLatin1String("hebrew")) {
|
||||
return KLocale::HebrewCalendar;
|
||||
} else if (calendarType == QLatin1String("hijri")) {
|
||||
return KLocale::IslamicCivilCalendar;
|
||||
} else if (calendarType == QLatin1String("indian-national")) {
|
||||
return KLocale::IndianNationalCalendar;
|
||||
} else if (calendarType == QLatin1String("jalali")) {
|
||||
return KLocale::JalaliCalendar;
|
||||
} else if (calendarType == QLatin1String("japanese")) {
|
||||
return KLocale::JapaneseCalendar;
|
||||
} else if (calendarType == QLatin1String("julian")) {
|
||||
return KLocale::JulianCalendar;
|
||||
} else if (calendarType == QLatin1String("minguo")) {
|
||||
return KLocale::MinguoCalendar;
|
||||
} else if (calendarType == QLatin1String("thai")) {
|
||||
return KLocale::ThaiCalendar;
|
||||
} else {
|
||||
return KLocale::QDateCalendar;
|
||||
}
|
||||
|
@ -170,28 +98,10 @@ QString KCalendarSystem::calendarType(KLocale::CalendarSystem calendarSystem)
|
|||
{
|
||||
if (calendarSystem == KLocale::QDateCalendar) {
|
||||
return QLatin1String("gregorian");
|
||||
} else if (calendarSystem == KLocale::CopticCalendar) {
|
||||
return QLatin1String("coptic");
|
||||
} else if (calendarSystem == KLocale::EthiopianCalendar) {
|
||||
return QLatin1String("ethiopian");
|
||||
} else if (calendarSystem == KLocale::GregorianCalendar) {
|
||||
return QLatin1String("gregorian-proleptic");
|
||||
} else if (calendarSystem == KLocale::HebrewCalendar) {
|
||||
return QLatin1String("hebrew");
|
||||
} else if (calendarSystem == KLocale::IndianNationalCalendar) {
|
||||
return QLatin1String("indian-national");
|
||||
} else if (calendarSystem == KLocale::IslamicCivilCalendar) {
|
||||
return QLatin1String("hijri");
|
||||
} else if (calendarSystem == KLocale::JalaliCalendar) {
|
||||
return QLatin1String("jalali");
|
||||
} else if (calendarSystem == KLocale::JapaneseCalendar) {
|
||||
return QLatin1String("japanese");
|
||||
} else if (calendarSystem == KLocale::JulianCalendar) {
|
||||
return QLatin1String("julian");
|
||||
} else if (calendarSystem == KLocale::MinguoCalendar) {
|
||||
return QLatin1String("minguo");
|
||||
} else if (calendarSystem == KLocale::ThaiCalendar) {
|
||||
return QLatin1String("thai");
|
||||
} else {
|
||||
return QLatin1String("gregorian");
|
||||
}
|
||||
|
|
|
@ -1337,18 +1337,9 @@ protected:
|
|||
|
||||
private:
|
||||
//Required for shared d-pointer as already private, remove in KDE5
|
||||
friend class KCalendarSystemCoptic;
|
||||
friend class KCalendarSystemEthiopian;
|
||||
friend class KCalendarSystemGregorian;
|
||||
friend class KCalendarSystemHebrew;
|
||||
friend class KCalendarSystemIndianNational;
|
||||
friend class KCalendarSystemIslamicCivil;
|
||||
friend class KCalendarSystemJalali;
|
||||
friend class KCalendarSystemJapanese;
|
||||
friend class KCalendarSystemJulian;
|
||||
friend class KCalendarSystemMinguo;
|
||||
friend class KCalendarSystemQDate;
|
||||
friend class KCalendarSystemThai;
|
||||
//Other friends that need access to protected/private functions
|
||||
friend class KDateTimeParser;
|
||||
|
||||
|
|
|
@ -1,565 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemcoptic_p.h"
|
||||
#include "kcalendarsystemprivate_p.h"
|
||||
#include "kcalendarsystemcopticprivate_p.h"
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "klocale.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
// Shared d pointer implementations
|
||||
|
||||
KCalendarSystemCopticPrivate::KCalendarSystemCopticPrivate(KCalendarSystemCoptic *q)
|
||||
: KCalendarSystemPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarSystemCopticPrivate::~KCalendarSystemCopticPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemCopticPrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::CopticCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemCopticPrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
// AM for Anno Martyrum or "Year of the Martyrs"
|
||||
name = i18nc("Calendar Era: Coptic Era of Martyrs, years > 0, LongFormat", "Anno Martyrum");
|
||||
shortName = i18nc("Calendar Era: Coptic Era of Martyrs, years > 0, ShortFormat", "AM");
|
||||
format = i18nc("(kdedt-format) Coptic, AM, full era year format used for %EY, e.g. 2000 AM", "%Ey %EC");
|
||||
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::monthsInYear(int year) const
|
||||
{
|
||||
Q_UNUSED(year)
|
||||
return 13;
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::daysInMonth(int year, int month) const
|
||||
{
|
||||
if (month == 13) {
|
||||
if (isLeapYear(year)) {
|
||||
return 6;
|
||||
} else {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
return 30;
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::daysInYear(int year) const
|
||||
{
|
||||
if (isLeapYear(year)) {
|
||||
return 366;
|
||||
} else {
|
||||
return 365;
|
||||
}
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::daysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCopticPrivate::isLeapYear(int year) const
|
||||
{
|
||||
//Uses same rule as Julian but offset by 1 year with year 3 being first leap year
|
||||
if (year < 1) {
|
||||
year = year + 2;
|
||||
} else {
|
||||
year = year + 1;
|
||||
}
|
||||
|
||||
if (year % 4 == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCopticPrivate::hasLeapMonths() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCopticPrivate::hasYearZero() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::maxDaysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::maxMonthsInYear() const
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::earliestValidYear() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int KCalendarSystemCopticPrivate::latestValidYear() const
|
||||
{
|
||||
return 9999;
|
||||
}
|
||||
|
||||
// Names taken from Bohairic dialect transliterations in http://www.copticheritage.org/parameters/copticheritage/calendar/The_Coptic_Calendar.pdf
|
||||
// These differ from the transliterations found on Wikipedia http://en.wikipedia.org/wiki/Coptic_calendar
|
||||
// These differ from the Sahidic dialect transliterations used in Dershowitz & Reingold which went out of use in the 11th centuary
|
||||
// These differ from the Arabic transliterations found on Wikipedia
|
||||
// These differ from the transliterations used in Mac OSX 10.6 Snow Leopard
|
||||
// The Boharic was initially chosen as this is the dialect apparantly in 'common' use in the Coptic Church.
|
||||
// But it could be argued the Arabic forms should be used as they are in 'common' usage in Eqypt
|
||||
// And where did the rest come from?
|
||||
//
|
||||
// Boharic Wikipedia Copt D&R Sahidic Wikipedia Arab Mac OSX
|
||||
// -------------- --------------- -------------- -------------- --------------
|
||||
// * Thoout Thout Thoout Tout Tout
|
||||
// * Paope Paopi Paope Baba Baba
|
||||
// * Hathor Hathor Athōr Hatour Hatour
|
||||
// * Kiahk Koiak Koiak Kiahk Kiahk
|
||||
// * Tobe Tobi Tōbe Touba Toba
|
||||
// * Meshir Meshir Meshir Amshir Amshir
|
||||
// * Paremhotep Paremhat Paremotep Baramhat Baramhat
|
||||
// * Parmoute Paremoude Paremoute Baramouda Baramouda
|
||||
// * Pashons Pashons Pashons Bashans Bashans
|
||||
// * Paone Paoni Paōne Ba'ouna Paona
|
||||
// * Epep Epip Epēp Abib Epep
|
||||
// * Mesore Mesori Mesorē Mesra Mesra
|
||||
// * Kouji nabot Pi Kogi Enavot Epagomenē Nasie
|
||||
// *
|
||||
QString KCalendarSystemCopticPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
|
||||
{
|
||||
Q_UNUSED(year);
|
||||
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Coptic month 1 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic month 2 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic month 3 - KLocale::NarrowName", "H").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic month 4 - KLocale::NarrowName", "K").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic month 5 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic month 6 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic month 7 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Coptic month 8 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Coptic month 9 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Coptic month 10 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Coptic month 11 - KLocale::NarrowName", "E").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Coptic month 12 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Coptic month 13 - KLocale::NarrowName", "K").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Coptic month 1 - KLocale::ShortName Possessive", "of Tho").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic month 2 - KLocale::ShortName Possessive", "of Pao").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic month 3 - KLocale::ShortName Possessive", "of Hat").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic month 4 - KLocale::ShortName Possessive", "of Kia").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic month 5 - KLocale::ShortName Possessive", "of Tob").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic month 6 - KLocale::ShortName Possessive", "of Mes").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic month 7 - KLocale::ShortName Possessive", "of Par").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Coptic month 8 - KLocale::ShortName Possessive", "of Pam").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Coptic month 9 - KLocale::ShortName Possessive", "of Pas").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Coptic month 10 - KLocale::ShortName Possessive", "of Pan").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Coptic month 11 - KLocale::ShortName Possessive", "of Epe").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Coptic month 12 - KLocale::ShortName Possessive", "of Meo").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Coptic month 13 - KLocale::ShortName Possessive", "of Kou").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && !possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Coptic month 1 - KLocale::ShortName", "Tho").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic month 2 - KLocale::ShortName", "Pao").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic month 3 - KLocale::ShortName", "Hat").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic month 4 - KLocale::ShortName", "Kia").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic month 5 - KLocale::ShortName", "Tob").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic month 6 - KLocale::ShortName", "Mes").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic month 7 - KLocale::ShortName", "Par").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Coptic month 8 - KLocale::ShortName", "Pam").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Coptic month 9 - KLocale::ShortName", "Pas").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Coptic month 10 - KLocale::ShortName", "Pan").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Coptic month 11 - KLocale::ShortName", "Epe").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Coptic month 12 - KLocale::ShortName", "Meo").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Coptic month 12 - KLocale::ShortName", "Kou").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::LongName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Coptic month 1 - KLocale::LongName Possessive", "of Thoout").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic month 2 - KLocale::LongName Possessive", "of Paope").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic month 3 - KLocale::LongName Possessive", "of Hathor").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic month 4 - KLocale::LongName Possessive", "of Kiahk").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic month 5 - KLocale::LongName Possessive", "of Tobe").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic month 6 - KLocale::LongName Possessive", "of Meshir").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic month 7 - KLocale::LongName Possessive", "of Paremhotep").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Coptic month 8 - KLocale::LongName Possessive", "of Parmoute").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Coptic month 9 - KLocale::LongName Possessive", "of Pashons").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Coptic month 10 - KLocale::LongName Possessive", "of Paone").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Coptic month 11 - KLocale::LongName Possessive", "of Epep").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Coptic month 12 - KLocale::LongName Possessive", "of Mesore").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Coptic month 12 - KLocale::LongName Possessive", "of Kouji nabot").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Default to LongName
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Coptic month 1 - KLocale::LongName", "Thoout").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic month 2 - KLocale::LongName", "Paope").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic month 3 - KLocale::LongName", "Hathor").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic month 4 - KLocale::LongName", "Kiahk").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic month 5 - KLocale::LongName", "Tobe").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic month 6 - KLocale::LongName", "Meshir").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic month 7 - KLocale::LongName", "Paremhotep").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Coptic month 8 - KLocale::LongName", "Parmoute").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Coptic month 9 - KLocale::LongName", "Pashons").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Coptic month 10 - KLocale::LongName", "Paone").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Coptic month 11 - KLocale::LongName", "Epep").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Coptic month 12 - KLocale::LongName", "Mesore").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Coptic month 12 - KLocale::LongName", "Kouji nabot").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Names taken from from the Sahidic dialect transliterations used in Dershowitz & Reingold which went out of use in the 11th centuary
|
||||
// Boharic or Arabic transliterations would be preferred but none could be found
|
||||
QString KCalendarSystemCopticPrivate::weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
|
||||
{
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Coptic weekday 1 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic weekday 2 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic weekday 3 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic weekday 4 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic weekday 5 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic weekday 6 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic weekday 7 - KLocale::NarrowName", "T").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName || format == KLocale:: ShortNumber) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Coptic weekday 1 - KLocale::ShortName", "Pes").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic weekday 2 - KLocale::ShortName", "Psh").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic weekday 3 - KLocale::ShortName", "Pef").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic weekday 4 - KLocale::ShortName", "Pti").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic weekday 5 - KLocale::ShortName", "Pso").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic weekday 6 - KLocale::ShortName", "Psa").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic weekday 7 - KLocale::ShortName", "Tky").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Coptic weekday 1 - KLocale::LongName", "Pesnau").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Coptic weekday 2 - KLocale::LongName", "Pshoment").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Coptic weekday 3 - KLocale::LongName", "Peftoou").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Coptic weekday 4 - KLocale::LongName", "Ptiou").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Coptic weekday 5 - KLocale::LongName", "Psoou").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Coptic weekday 6 - KLocale::LongName", "Psabbaton").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Coptic weekday 7 - KLocale::LongName", "Tkyriakē").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemCoptic::KCalendarSystemCoptic(const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemCopticPrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemCoptic::KCalendarSystemCoptic(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemCopticPrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemCoptic::KCalendarSystemCoptic(KCalendarSystemCopticPrivate &dd,
|
||||
const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystem(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemCoptic::~KCalendarSystemCoptic()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemCoptic::calendarType() const
|
||||
{
|
||||
return QLatin1String("coptic");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemCoptic::epoch() const
|
||||
{
|
||||
//0001-01-01, no Year 0.
|
||||
//0284-08-29 AD Julian
|
||||
return QDate::fromJulianDay(1825030);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemCoptic::earliestValidDate() const
|
||||
{
|
||||
//0001-01-01, no Year 0.
|
||||
//0284-08-29 AD Julian
|
||||
return QDate::fromJulianDay(1825030);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemCoptic::latestValidDate() const
|
||||
{
|
||||
// Set to last day of year 9999 until confirm date formats & widgets support > 9999
|
||||
//9999-12-30
|
||||
//10283-08-29 AD Julian
|
||||
return QDate::fromJulianDay(5477164);
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystem::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(date);
|
||||
}
|
||||
|
||||
QString KCalendarSystemCoptic::monthName(int month, int year, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(month, year, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemCoptic::monthName(const QDate &date, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(date, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemCoptic::weekDayName(int weekDay, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(weekDay, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemCoptic::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(date, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isLunar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isLunisolar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isSolar() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
//The Coptic calendar has 12 months of 30 days, a 13th month of 5 or 6 days,
|
||||
//and a leap year every 4th year without fail that falls on the last day of
|
||||
//the year, starting from year 3.
|
||||
|
||||
//Use a fake year 0 for our epoch instead of the real epoch in year 1. This is because year 3
|
||||
//is the first leap year and a pattern of 365/365/366/365 is hard to calculate, instead a
|
||||
//pattern of 365/365/365/366 with the leap day the very last day makes the maths easier.
|
||||
|
||||
//Day number in the fake epoch, 0 indexed
|
||||
int dayInEpoch = jd - (epoch().toJulianDay() - 365);
|
||||
//How many full 4 year leap cycles have been completed, 1461 = (365*3)+366
|
||||
int leapCyclesCompleted = dayInEpoch / 1461;
|
||||
//Which year are we in the current 4 year leap cycle, 0 indexed
|
||||
//Need the qMin as day 366 of 4th year of cycle returns following year (max 3 as 0 index)
|
||||
int yearInCurrentLeapCycle = qMin(3, (dayInEpoch % 1461) / 365);
|
||||
//Calculate the year
|
||||
year = (leapCyclesCompleted * 4) + yearInCurrentLeapCycle;
|
||||
//Days since the fake epoch up to 1st day of this year
|
||||
int daysBeforeThisYear = (year * 365) + (year / 4);
|
||||
//Gives the day number in this year, 0 indexed
|
||||
int dayOfThisYear = dayInEpoch - daysBeforeThisYear;
|
||||
//Then just calculate month and day from that based on regular 30 day months
|
||||
month = ((dayOfThisYear) / 30) + 1;
|
||||
day = dayOfThisYear - ((month - 1) * 30) + 1;
|
||||
|
||||
// If year is -ve then is BC. In Coptic there is no year 0, but the maths
|
||||
// is easier if we pretend there is, so internally year of 0 = 1BC = -1 outside
|
||||
if (year < 1) {
|
||||
year = year - 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCalendarSystemCoptic::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
//The Coptic calendar has 12 months of 30 days, a 13th month of 5 or 6 days,
|
||||
//and a leap year every 4th year without fail that falls on the last day of
|
||||
//the year, starting from year 3. This simple repeating pattern makes calculating
|
||||
// a jd the simple process taking the epoch jd and adding on the years months and
|
||||
//days required.
|
||||
|
||||
// If year is -ve then is 'BC'. In Coptic there is no year 0, but the maths
|
||||
// is easier if we pretend there is, so internally year of -1 = 1BC = 0 internally
|
||||
int y;
|
||||
if (year < 1) {
|
||||
y = year + 1;
|
||||
} else {
|
||||
y = year;
|
||||
}
|
||||
|
||||
jd = epoch().toJulianDay() - 1 // jd of day before Epoch
|
||||
+ ((y - 1) * 365) // Add all normal days in years preceding
|
||||
+ (y / 4) // Add all leap days in years preceding
|
||||
+ ((month - 1) * 30) // Add days this year in months preceding
|
||||
+ day; // Add days in this month
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMCOPTIC_H
|
||||
#define KCALENDARSYSTEMCOPTIC_H
|
||||
|
||||
#include "kcalendarsystem.h"
|
||||
|
||||
class KCalendarSystemCopticPrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Coptic calendar implementation which is also the Ethiopian calendar
|
||||
*
|
||||
* @b license GNU-LGPL v.2 or later
|
||||
*
|
||||
* @see KLocale,KCalendarSystem
|
||||
*
|
||||
* @author John Layt <john@layt.net>
|
||||
*/
|
||||
class KCalendarSystemCoptic: public KCalendarSystem
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemCoptic(const KLocale *locale = 0);
|
||||
explicit KCalendarSystemCoptic(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemCoptic();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemCoptic(KCalendarSystemCopticPrivate &dd, const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemCoptic)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMCOPTIC_H
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
Copyright 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMCOPTICPRIVATE_H
|
||||
#define KCALENDARSYSTEMCOPTICPRIVATE_H
|
||||
|
||||
#include "kcalendarsystemprivate_p.h"
|
||||
|
||||
class KCalendarSystemCopticPrivate : public KCalendarSystemPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemCopticPrivate(KCalendarSystemCoptic *q);
|
||||
|
||||
virtual ~KCalendarSystemCopticPrivate();
|
||||
|
||||
// Virtual methods each calendar system must re-implement
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual int monthsInYear(int year) const;
|
||||
virtual int daysInMonth(int year, int month) const;
|
||||
virtual int daysInYear(int year) const;
|
||||
virtual int daysInWeek() const;
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool hasLeapMonths() const;
|
||||
virtual bool hasYearZero() const;
|
||||
virtual int maxDaysInWeek() const;
|
||||
virtual int maxMonthsInYear() const;
|
||||
virtual int earliestValidYear() const;
|
||||
virtual int latestValidYear() const;
|
||||
virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const;
|
||||
virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMCOPTICPRIVATE_H
|
|
@ -1,413 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemethiopian_p.h"
|
||||
#include "kcalendarsystemcopticprivate_p.h"
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "klocale.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
//Reuse the Coptic private implementation
|
||||
class KCalendarSystemEthiopianPrivate : public KCalendarSystemCopticPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemEthiopianPrivate(KCalendarSystemEthiopian *q) : KCalendarSystemCopticPrivate(q) {
|
||||
}
|
||||
|
||||
virtual ~KCalendarSystemEthiopianPrivate() {
|
||||
}
|
||||
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const;
|
||||
virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
|
||||
};
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemEthiopianPrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::EthiopianCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemEthiopianPrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
// Incarnation Era, Amätä Mehrät, "Year of Mercy".
|
||||
name = i18nc("Calendar Era: Ethiopian Incarnation Era, years > 0, LongFormat", "Amata Mehrat");
|
||||
shortName = i18nc("Calendar Era: Ethiopian Incarnation Era, years > 0, ShortFormat", "AM");
|
||||
format = i18nc("(kdedt-format) Ethiopian, AM, full era year format used for %EY, e.g. 2000 AM", "%Ey %EC");
|
||||
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
// Names taken from http://www.ethiopianembassy.at/dates_cycles.htm, alternative transliterations exist
|
||||
QString KCalendarSystemEthiopianPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
|
||||
{
|
||||
Q_UNUSED(year);
|
||||
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian month 1 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian month 2 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian month 3 - KLocale::NarrowName", "H").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian month 4 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian month 5 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian month 6 - KLocale::NarrowName", "Y").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian month 7 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Ethiopian month 8 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Ethiopian month 9 - KLocale::NarrowName", "G").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Ethiopian month 10 - KLocale::NarrowName", "S").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Ethiopian month 11 - KLocale::NarrowName", "H").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Ethiopian month 12 - KLocale::NarrowName", "N").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Ethiopian month 13 - KLocale::NarrowName", "P").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian month 1 - KLocale::ShortName Possessive", "of Mes").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian month 2 - KLocale::ShortName Possessive", "of Teq").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian month 3 - KLocale::ShortName Possessive", "of Hed").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian month 4 - KLocale::ShortName Possessive", "of Tah").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian month 5 - KLocale::ShortName Possessive", "of Ter").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian month 6 - KLocale::ShortName Possessive", "of Yak").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian month 7 - KLocale::ShortName Possessive", "of Mag").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Ethiopian month 8 - KLocale::ShortName Possessive", "of Miy").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Ethiopian month 9 - KLocale::ShortName Possessive", "of Gen").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Ethiopian month 10 - KLocale::ShortName Possessive", "of Sen").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Ethiopian month 11 - KLocale::ShortName Possessive", "of Ham").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Ethiopian month 12 - KLocale::ShortName Possessive", "of Neh").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Ethiopian month 13 - KLocale::ShortName Possessive", "of Pag").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && !possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian month 1 - KLocale::ShortName", "Mes").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian month 2 - KLocale::ShortName", "Teq").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian month 3 - KLocale::ShortName", "Hed").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian month 4 - KLocale::ShortName", "Tah").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian month 5 - KLocale::ShortName", "Ter").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian month 6 - KLocale::ShortName", "Yak").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian month 7 - KLocale::ShortName", "Mag").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Ethiopian month 8 - KLocale::ShortName", "Miy").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Ethiopian month 9 - KLocale::ShortName", "Gen").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Ethiopian month 10 - KLocale::ShortName", "Sen").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Ethiopian month 11 - KLocale::ShortName", "Ham").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Ethiopian month 12 - KLocale::ShortName", "Neh").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Ethiopian month 13 - KLocale::ShortName", "Pag").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::LongName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian month 1 - KLocale::LongName Possessive", "of Meskerem").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian month 2 - KLocale::LongName Possessive", "of Tequemt").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian month 3 - KLocale::LongName Possessive", "of Hedar").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian month 4 - KLocale::LongName Possessive", "of Tahsas").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian month 5 - KLocale::LongName Possessive", "of Ter").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian month 6 - KLocale::LongName Possessive", "of Yakatit").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian month 7 - KLocale::LongName Possessive", "of Magabit").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Ethiopian month 8 - KLocale::LongName Possessive", "of Miyazya").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Ethiopian month 9 - KLocale::LongName Possessive", "of Genbot").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Ethiopian month 10 - KLocale::LongName Possessive", "of Sene").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Ethiopian month 11 - KLocale::LongName Possessive", "of Hamle").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Ethiopian month 12 - KLocale::LongName Possessive", "of Nehase").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Ethiopian month 13 - KLocale::LongName Possessive", "of Pagumen").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Default to LongName
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian month 1 - KLocale::LongName", "Meskerem").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian month 2 - KLocale::LongName", "Tequemt").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian month 3 - KLocale::LongName", "Hedar").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian month 4 - KLocale::LongName", "Tahsas").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian month 5 - KLocale::LongName", "Ter").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian month 6 - KLocale::LongName", "Yakatit").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian month 7 - KLocale::LongName", "Magabit").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Ethiopian month 8 - KLocale::LongName", "Miyazya").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Ethiopian month 9 - KLocale::LongName", "Genbot").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Ethiopian month 10 - KLocale::LongName", "Sene").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Ethiopian month 11 - KLocale::LongName", "Hamle").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Ethiopian month 12 - KLocale::LongName", "Nehase").toString(locale());
|
||||
case 13:
|
||||
return ki18nc("Ethiopian month 13 - KLocale::LongName", "Pagumen").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Names taken from http://www.ethiopianembassy.at/dates_cycles.htm, alternative transliterations exist
|
||||
QString KCalendarSystemEthiopianPrivate::weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
|
||||
{
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian weekday 1 - KLocale::NarrowName ", "S").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian weekday 2 - KLocale::NarrowName ", "M").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian weekday 3 - KLocale::NarrowName ", "R").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian weekday 4 - KLocale::NarrowName ", "H").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian weekday 5 - KLocale::NarrowName ", "A").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian weekday 6 - KLocale::NarrowName ", "Q").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian weekday 7 - KLocale::NarrowName ", "E").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName || format == KLocale:: ShortNumber) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian weekday 1 - KLocale::ShortName", "Seg").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian weekday 2 - KLocale::ShortName", "Mak").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian weekday 3 - KLocale::ShortName", "Rob").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian weekday 4 - KLocale::ShortName", "Ham").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian weekday 5 - KLocale::ShortName", "Arb").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian weekday 6 - KLocale::ShortName", "Qed").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian weekday 7 - KLocale::ShortName", "Ehu").toString(locale());
|
||||
default: return QString();
|
||||
}
|
||||
}
|
||||
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Ethiopian weekday 1 - KLocale::LongName", "Segno").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Ethiopian weekday 2 - KLocale::LongName", "Maksegno").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Ethiopian weekday 3 - KLocale::LongName", "Rob").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Ethiopian weekday 4 - KLocale::LongName", "Hamus").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Ethiopian weekday 5 - KLocale::LongName", "Arb").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Ethiopian weekday 6 - KLocale::LongName", "Qedame").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Ethiopian weekday 7 - KLocale::LongName", "Ehud").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemEthiopian::KCalendarSystemEthiopian(const KLocale *locale)
|
||||
: KCalendarSystemCoptic(*new KCalendarSystemEthiopianPrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemEthiopian::KCalendarSystemEthiopian(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemCoptic(*new KCalendarSystemEthiopianPrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemEthiopian::KCalendarSystemEthiopian(KCalendarSystemEthiopianPrivate &dd,
|
||||
const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemCoptic(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemEthiopian::~KCalendarSystemEthiopian()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemEthiopian::calendarType() const
|
||||
{
|
||||
return QLatin1String("ethiopian");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemEthiopian::epoch() const
|
||||
{
|
||||
//0001-01-01, no Year 0.
|
||||
//0008-08-29 AD Julian
|
||||
return QDate::fromJulianDay(1724221);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemEthiopian::earliestValidDate() const
|
||||
{
|
||||
//0001-01-01, no Year 0.
|
||||
//0008-08-29 AD Julian
|
||||
return QDate::fromJulianDay(1724221);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemEthiopian::latestValidDate() const
|
||||
{
|
||||
// Set to last day of year 9999 until confirm date formats & widgets support > 9999
|
||||
//9999-12-30
|
||||
//100008-08-29 AD Julian
|
||||
return QDate::fromJulianDay(5376721);
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystemCoptic::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemCoptic::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystemCoptic::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemCoptic::isLeapYear(date);
|
||||
}
|
||||
|
||||
QString KCalendarSystemEthiopian::monthName(int month, int year, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemCoptic::monthName(month, year, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemEthiopian::monthName(const QDate &date, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemCoptic::monthName(date, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemEthiopian::weekDayName(int weekDay, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemCoptic::weekDayName(weekDay, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemEthiopian::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemCoptic::weekDayName(date, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isLunar() const
|
||||
{
|
||||
return KCalendarSystemCoptic::isLunar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isLunisolar() const
|
||||
{
|
||||
return KCalendarSystemCoptic::isLunisolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isSolar() const
|
||||
{
|
||||
return KCalendarSystemCoptic::isSolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
return KCalendarSystemCoptic::julianDayToDate(jd, year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemEthiopian::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
return KCalendarSystemCoptic::dateToJulianDay(year, month, day, jd);
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMETHIOPIAN_H
|
||||
#define KCALENDARSYSTEMETHIOPIAN_H
|
||||
|
||||
#include "kcalendarsystemcoptic_p.h"
|
||||
|
||||
class KCalendarSystemEthiopianPrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Ethiopian calendar implementation which is the Coptic calendar
|
||||
* but with a differenct Epoch and month/weekday names
|
||||
*
|
||||
* @b license GNU-LGPL v.2 or later
|
||||
*
|
||||
* @see KLocale,KCalendarSystem
|
||||
*
|
||||
* @author John Layt <john@layt.net>
|
||||
*/
|
||||
class KCalendarSystemEthiopian: public KCalendarSystemCoptic
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemEthiopian(const KLocale *locale = 0);
|
||||
explicit KCalendarSystemEthiopian(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemEthiopian();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemEthiopian(KCalendarSystemEthiopianPrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemEthiopian)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMETHIOPIAN_H
|
File diff suppressed because it is too large
Load diff
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2002-2003 Carlos Moro <cfmoro@correo.uniovi.es>
|
||||
Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
|
||||
Copyright 2007, 2010 John Layt <john@layt.net>
|
||||
Calendar conversion routines based on Hdate v6, by Amos
|
||||
Shapir 1978 (rev. 1985, 1992)
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMHEBREW_H
|
||||
#define KCALENDARSYSTEMHEBREW_H
|
||||
|
||||
#include "kcalendarsystem.h"
|
||||
|
||||
class KCalendarSystemHebrewPrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Hebrew calendar implementation.
|
||||
*
|
||||
* The Hebrew calendar is the traditional calendar used by the Jewish faith
|
||||
*
|
||||
* @see KLocale,KCalendarSystem,KCalendarSystemFactory
|
||||
*
|
||||
* @author Hans Petter Bieker <bieker@kde.org>
|
||||
*/
|
||||
class KCalendarSystemHebrew : public KCalendarSystem
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemHebrew(const KLocale * locale = 0);
|
||||
explicit KCalendarSystemHebrew(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemHebrew();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual int dayOfWeek(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemHebrew(KCalendarSystemHebrewPrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemHebrew)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMHEBREW_H
|
|
@ -1,544 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemindiannational_p.h"
|
||||
#include "kcalendarsystemprivate_p.h"
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "klocale.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
class KCalendarSystemIndianNationalPrivate : public KCalendarSystemPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemIndianNationalPrivate(KCalendarSystemIndianNational *q);
|
||||
|
||||
virtual ~KCalendarSystemIndianNationalPrivate();
|
||||
|
||||
// Virtual methods each calendar system must re-implement
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual int monthsInYear(int year) const;
|
||||
virtual int daysInMonth(int year, int month) const;
|
||||
virtual int daysInYear(int year) const;
|
||||
virtual int daysInWeek() const;
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool hasLeapMonths() const;
|
||||
virtual bool hasYearZero() const;
|
||||
virtual int maxDaysInWeek() const;
|
||||
virtual int maxMonthsInYear() const;
|
||||
virtual int earliestValidYear() const;
|
||||
virtual int latestValidYear() const;
|
||||
virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const;
|
||||
virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
|
||||
};
|
||||
|
||||
// Shared d pointer base class definitions
|
||||
|
||||
KCalendarSystemIndianNationalPrivate::KCalendarSystemIndianNationalPrivate(KCalendarSystemIndianNational *q)
|
||||
: KCalendarSystemPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarSystemIndianNationalPrivate::~KCalendarSystemIndianNationalPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemIndianNationalPrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::IndianNationalCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemIndianNationalPrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
// Saka Era
|
||||
name = i18nc("Calendar Era: Indian National Saka Era, years > 0, LongFormat", "Saka Era");
|
||||
shortName = i18nc("Calendar Era: Indian National Saka Era, years > 0, ShortFormat", "SE");
|
||||
format = i18nc("(kdedt-format) Indian National, SE, full era year format used for %EY, e.g. 2000 SE", "%Ey %EC");
|
||||
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::monthsInYear(int year) const
|
||||
{
|
||||
Q_UNUSED(year)
|
||||
return 12;
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::daysInMonth(int year, int month) const
|
||||
{
|
||||
if (month == 1) {
|
||||
if (isLeapYear(year)) {
|
||||
return 31;
|
||||
} else {
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
|
||||
if (month >= 2 && month <= 6) {
|
||||
return 31;
|
||||
}
|
||||
|
||||
return 30;
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::daysInYear(int year) const
|
||||
{
|
||||
if (isLeapYear(year)) {
|
||||
return 366;
|
||||
} else {
|
||||
return 365;
|
||||
}
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::daysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNationalPrivate::isLeapYear(int year) const
|
||||
{
|
||||
//Uses same rule as Gregorian, and is explicitly synchronized to Gregorian
|
||||
//so add 78 years to get Gregorian year and apply Gregorian calculation
|
||||
year = year + 78;
|
||||
if (!hasYearZero() && year < 1) {
|
||||
year = year + 1;
|
||||
}
|
||||
|
||||
if (year % 4 == 0) {
|
||||
if (year % 100 != 0) {
|
||||
return true;
|
||||
} else if (year % 400 == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNationalPrivate::hasLeapMonths() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNationalPrivate::hasYearZero() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::maxDaysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::maxMonthsInYear() const
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::earliestValidYear() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int KCalendarSystemIndianNationalPrivate::latestValidYear() const
|
||||
{
|
||||
return 9999;
|
||||
}
|
||||
|
||||
QString KCalendarSystemIndianNationalPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
|
||||
{
|
||||
Q_UNUSED(year);
|
||||
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Indian National month 1 - KLocale::NarrowName", "C").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National month 2 - KLocale::NarrowName", "V").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National month 3 - KLocale::NarrowName", "J").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National month 4 - KLocale::NarrowName", "Ā").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National month 5 - KLocale::NarrowName", "S").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National month 6 - KLocale::NarrowName", "B").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National month 7 - KLocale::NarrowName", "Ā").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Indian National month 8 - KLocale::NarrowName", "K").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Indian National month 9 - KLocale::NarrowName", "A").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Indian National month 10 - KLocale::NarrowName", "P").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Indian National month 11 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Indian National month 12 - KLocale::NarrowName", "P").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Indian National month 1 - KLocale::ShortName Possessive", "of Cha").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National month 2 - KLocale::ShortName Possessive", "of Vai").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National month 3 - KLocale::ShortName Possessive", "of Jya").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National month 4 - KLocale::ShortName Possessive", "of Āsh").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National month 5 - KLocale::ShortName Possessive", "of Shr").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National month 6 - KLocale::ShortName Possessive", "of Bhā").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National month 7 - KLocale::ShortName Possessive", "of Āsw").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Indian National month 8 - KLocale::ShortName Possessive", "of Kār").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Indian National month 9 - KLocale::ShortName Possessive", "of Agr").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Indian National month 10 - KLocale::ShortName Possessive", "of Pau").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Indian National month 11 - KLocale::ShortName Possessive", "of Māg").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Indian National month 12 - KLocale::ShortName Possessive", "of Phā").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && !possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Indian National month 1 - KLocale::ShortName", "Cha").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National month 2 - KLocale::ShortName", "Vai").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National month 3 - KLocale::ShortName", "Jya").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National month 4 - KLocale::ShortName", "Āsh").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National month 5 - KLocale::ShortName", "Shr").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National month 6 - KLocale::ShortName", "Bhā").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National month 7 - KLocale::ShortName", "Āsw").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Indian National month 8 - KLocale::ShortName", "Kār").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Indian National month 9 - KLocale::ShortName", "Agr").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Indian National month 10 - KLocale::ShortName", "Pau").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Indian National month 11 - KLocale::ShortName", "Māg").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Indian National month 12 - KLocale::ShortName", "Phā").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::LongName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Indian National month 1 - KLocale::LongName Possessive", "of Chaitra").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National month 2 - KLocale::LongName Possessive", "of Vaishākh").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National month 3 - KLocale::LongName Possessive", "of Jyaishtha").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National month 4 - KLocale::LongName Possessive", "of Āshādha").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National month 5 - KLocale::LongName Possessive", "of Shrāvana").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National month 6 - KLocale::LongName Possessive", "of Bhādrapad").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National month 7 - KLocale::LongName Possessive", "of Āshwin").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Indian National month 8 - KLocale::LongName Possessive", "of Kārtik").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Indian National month 9 - KLocale::LongName Possessive", "of Agrahayana").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Indian National month 10 - KLocale::LongName Possessive", "of Paush").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Indian National month 11 - KLocale::LongName Possessive", "of Māgh").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Indian National month 12 - KLocale::LongName Possessive", "of Phālgun").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Default to LongName
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Indian National month 1 - KLocale::LongName", "Chaitra").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National month 2 - KLocale::LongName", "Vaishākh").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National month 3 - KLocale::LongName", "Jyaishtha").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National month 4 - KLocale::LongName", "Āshādha").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National month 5 - KLocale::LongName", "Shrāvana").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National month 6 - KLocale::LongName", "Bhādrapad").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National month 7 - KLocale::LongName", "Āshwin").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Indian National month 8 - KLocale::LongName", "Kārtik").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Indian National month 9 - KLocale::LongName", "Agrahayana").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Indian National month 10 - KLocale::LongName", "Paush").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Indian National month 11 - KLocale::LongName", "Māgh").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Indian National month 12 - KLocale::LongName", "Phālgun").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString KCalendarSystemIndianNationalPrivate::weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
|
||||
{
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Indian National weekday 1 - KLocale::NarrowName ", "S").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National weekday 2 - KLocale::NarrowName ", "M").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National weekday 3 - KLocale::NarrowName ", "B").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National weekday 4 - KLocale::NarrowName ", "G").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National weekday 5 - KLocale::NarrowName ", "S").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National weekday 6 - KLocale::NarrowName ", "S").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National weekday 7 - KLocale::NarrowName ", "R").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName || format == KLocale:: ShortNumber) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Indian National weekday 1 - KLocale::ShortName", "Som").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National weekday 2 - KLocale::ShortName", "Mañ").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National weekday 3 - KLocale::ShortName", "Bud").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National weekday 4 - KLocale::ShortName", "Gur").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National weekday 5 - KLocale::ShortName", "Suk").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National weekday 6 - KLocale::ShortName", "San").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National weekday 7 - KLocale::ShortName", "Rav").toString(locale());
|
||||
default: return QString();
|
||||
}
|
||||
}
|
||||
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Indian National weekday 1 - KLocale::LongName", "Somavãra").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Indian National weekday 2 - KLocale::LongName", "Mañgalvã").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Indian National weekday 3 - KLocale::LongName", "Budhavãra").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Indian National weekday 4 - KLocale::LongName", "Guruvãra").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Indian National weekday 5 - KLocale::LongName", "Sukravãra").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Indian National weekday 6 - KLocale::LongName", "Sanivãra").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Indian National weekday 7 - KLocale::LongName", "Raviãra").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemIndianNational::KCalendarSystemIndianNational(const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemIndianNationalPrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemIndianNational::KCalendarSystemIndianNational(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemIndianNationalPrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemIndianNational::KCalendarSystemIndianNational(KCalendarSystemIndianNationalPrivate &dd,
|
||||
const KSharedConfig::Ptr config,
|
||||
const KLocale *locale)
|
||||
: KCalendarSystem(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemIndianNational::~KCalendarSystemIndianNational()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemIndianNational::calendarType() const
|
||||
{
|
||||
return QLatin1String("indian-national");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemIndianNational::epoch() const
|
||||
{
|
||||
//0000-01-01, has Year 0.
|
||||
//0078-03-22 AD Gregorian / 0078-03-24 AD Julian
|
||||
return QDate::fromJulianDay(1749994);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemIndianNational::earliestValidDate() const
|
||||
{
|
||||
//0000-01-01, has Year 0.
|
||||
//0078-03-22 AD Gregorian / 0078-03-24 AD Julian
|
||||
//Don't do proleptic yet, need to check
|
||||
return QDate::fromJulianDay(1749630);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemIndianNational::latestValidDate() const
|
||||
{
|
||||
// Set to last day of year 9999 until confirm date formats & widgets support > 9999
|
||||
//9999-12-30
|
||||
//10078-03-21 AD Gregorian
|
||||
return QDate::fromJulianDay(5402054);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystem::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(date);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIndianNational::monthName(int month, int year, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(month, year, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIndianNational::monthName(const QDate &date, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(date, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIndianNational::weekDayName(int weekDay, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(weekDay, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIndianNational::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(date, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isLunar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isLunisolar() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isSolar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
int L, N, I, J, D, M, Y;
|
||||
|
||||
// "Explanatory Supplement to the Astronomical Almanac" 2006 section 12.94 pp 605-606
|
||||
// Originally from "Report of the Calendar Reform Committee" 1955
|
||||
L = jd + 68518;
|
||||
N = (4 * L) / 146097;
|
||||
L = L - (146097 * N + 3) / 4;
|
||||
I = (4000 * (L + 1)) / 1461001;
|
||||
L = L - (1461 * I) / 4 + 1;
|
||||
J = ((L - 1) / 31) * (1 - L / 185) + (L / 185) * ((L - 156) / 30 + 5) - L / 366;
|
||||
D = L - 31 * J + ((J + 2) / 8) * (J - 5);
|
||||
L = J / 11;
|
||||
M = J + 2 - 12 * L;
|
||||
Y = 100 * (N - 49) + L + I - 78;
|
||||
|
||||
day = D;
|
||||
month = M;
|
||||
year = Y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIndianNational::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
int Y = year;
|
||||
int M = month;
|
||||
int D = day;
|
||||
|
||||
// "Explanatory Supplement to the Astronomical Almanac" 2006 section 12.94 pp 605-606
|
||||
// Originally from "Report of the Calendar Reform Committee" 1955
|
||||
jd = 365 * Y
|
||||
+ (Y + 78 - 1 / M) / 4
|
||||
+ 31 * M
|
||||
- (M + 9) / 11
|
||||
- (M / 7) * (M - 7)
|
||||
- (3 * ((Y + 78 - 1 / M) / 100 + 1)) / 4
|
||||
+ D
|
||||
+ 1749579;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMINDIANNATIONAL_H
|
||||
#define KCALENDARSYSTEMINDIANNATIONAL_H
|
||||
|
||||
#include "kcalendarsystem.h"
|
||||
|
||||
class KCalendarSystemIndianNationalPrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Indian National / Civil / Saka calendar implementation.
|
||||
*
|
||||
* Note: This is is the purely civil arithmetic calendar, the religious
|
||||
* versions of the calendar will be implemented separately once
|
||||
* astronomical calendars are implemented.
|
||||
*
|
||||
* @b license GNU-LGPL v.2 or later
|
||||
*
|
||||
* @see KLocale,KCalendarSystem
|
||||
*
|
||||
* @author John Layt <john@layt.net>
|
||||
*/
|
||||
class KCalendarSystemIndianNational: public KCalendarSystem
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemIndianNational(const KLocale *locale = 0);
|
||||
explicit KCalendarSystemIndianNational(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemIndianNational();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemIndianNational(KCalendarSystemIndianNationalPrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemIndianNational)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMINDIANNATIONAL_H
|
|
@ -1,591 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2002-2003 Carlos Moro <cfmoro@correo.uniovi.es>
|
||||
Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
|
||||
Copyright 2007, 2008, 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemislamiccivil_p.h"
|
||||
#include "kcalendarsystemprivate_p.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
class KCalendarSystemIslamicCivilPrivate : public KCalendarSystemPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemIslamicCivilPrivate(KCalendarSystemIslamicCivil *q);
|
||||
|
||||
virtual ~KCalendarSystemIslamicCivilPrivate();
|
||||
|
||||
// Virtual methods each calendar system must re-implement
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual int monthsInYear(int year) const;
|
||||
virtual int daysInMonth(int year, int month) const;
|
||||
virtual int daysInYear(int year) const;
|
||||
virtual int daysInWeek() const;
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool hasLeapMonths() const;
|
||||
virtual bool hasYearZero() const;
|
||||
virtual int maxDaysInWeek() const;
|
||||
virtual int maxMonthsInYear() const;
|
||||
virtual int earliestValidYear() const;
|
||||
virtual int latestValidYear() const;
|
||||
virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const;
|
||||
virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
|
||||
};
|
||||
|
||||
// Shared d pointer base class definitions
|
||||
|
||||
KCalendarSystemIslamicCivilPrivate::KCalendarSystemIslamicCivilPrivate(KCalendarSystemIslamicCivil *q)
|
||||
: KCalendarSystemPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarSystemIslamicCivilPrivate::~KCalendarSystemIslamicCivilPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemIslamicCivilPrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::IslamicCivilCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemIslamicCivilPrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
// Islamic Era, Anno Hegirae, "Year of the Hijra".
|
||||
name = i18nc("Calendar Era: Hijri Islamic Era, years > 0, LongFormat", "Anno Hegirae");
|
||||
shortName = i18nc("Calendar Era: Hijri Islamic Era, years > 0, ShortFormat", "AH");
|
||||
format = i18nc("(kdedt-format) Hijri, AH, full era year format used for %EY, e.g. 2000 AH", "%Ey %EC");
|
||||
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::monthsInYear(int year) const
|
||||
{
|
||||
Q_UNUSED(year)
|
||||
return 12;
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::daysInMonth(int year, int month) const
|
||||
{
|
||||
if (month == 12 && isLeapYear(year)) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
if (month % 2 == 0) { // Even number months have 29 days
|
||||
return 29;
|
||||
} else { // Odd number months have 30 days
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::daysInYear(int year) const
|
||||
{
|
||||
if (isLeapYear(year)) {
|
||||
return 355;
|
||||
} else {
|
||||
return 354;
|
||||
}
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::daysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivilPrivate::isLeapYear(int year) const
|
||||
{
|
||||
// Years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29 of the 30 year cycle
|
||||
|
||||
/*
|
||||
The following C++ code is translated from the Lisp code
|
||||
in ``Calendrical Calculations'' by Nachum Dershowitz and
|
||||
Edward M. Reingold, Software---Practice & Experience,
|
||||
vol. 20, no. 9 (September, 1990), pp. 899--928.
|
||||
|
||||
This code is in the public domain, but any use of it
|
||||
should publically acknowledge its source.
|
||||
*/
|
||||
|
||||
if ((((11 * year) + 14) % 30) < 11) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The following variations will be implemented in separate classes in 4.5
|
||||
// May be cleaner to formally define using a case statement switch on (year % 30)
|
||||
|
||||
// Variation used by Bar Habraeus / Graves / Birashk / Some Microsoft products
|
||||
// Years 2, 5, 7, 10, 13, 15, 18, 21, 24, 26, 29 of the 30 year cycle
|
||||
// if ( ( ( ( 11 * year ) + 15 ) % 30 ) < 11 ) {
|
||||
|
||||
// Variation used by Bohras / Sahifa with epoch 15 July 622 jd = 1948440
|
||||
// Years 2, 5, 8, 10, 13, 16, 19, 21, 24, 27, 29 of the 30 year cycle
|
||||
// if ( ( ( ( 11 * year ) + 1 ) % 30 ) < 11 ) {
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivilPrivate::hasLeapMonths() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivilPrivate::hasYearZero() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::maxDaysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::maxMonthsInYear() const
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::earliestValidYear() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int KCalendarSystemIslamicCivilPrivate::latestValidYear() const
|
||||
{
|
||||
return 9999;
|
||||
}
|
||||
|
||||
QString KCalendarSystemIslamicCivilPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
|
||||
{
|
||||
Q_UNUSED(year);
|
||||
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Hijri month 1 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri month 2 - KLocale::NarrowName", "S").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri month 3 - KLocale::NarrowName", "A").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri month 4 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri month 5 - KLocale::NarrowName", "A").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri month 6 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri month 7 - KLocale::NarrowName", "R").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Hijri month 8 - KLocale::NarrowName", "S").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Hijri month 9 - KLocale::NarrowName", "R").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Hijri month 10 - KLocale::NarrowName", "S").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Hijri month 11 - KLocale::NarrowName", "Q").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Hijri month 12 - KLocale::NarrowName", "H").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Hijri month 1 - KLocale::ShortName Possessive", "of Muh").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri month 2 - KLocale::ShortName Possessive", "of Saf").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri month 3 - KLocale::ShortName Possessive", "of R.A").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri month 4 - KLocale::ShortName Possessive", "of R.T").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri month 5 - KLocale::ShortName Possessive", "of J.A").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri month 6 - KLocale::ShortName Possessive", "of J.T").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri month 7 - KLocale::ShortName Possessive", "of Raj").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Hijri month 8 - KLocale::ShortName Possessive", "of Sha").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Hijri month 9 - KLocale::ShortName Possessive", "of Ram").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Hijri month 10 - KLocale::ShortName Possessive", "of Shw").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Hijri month 11 - KLocale::ShortName Possessive", "of Qid").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Hijri month 12 - KLocale::ShortName Possessive", "of Hij").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && !possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Hijri month 1 - KLocale::ShortName", "Muh").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri month 2 - KLocale::ShortName", "Saf").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri month 3 - KLocale::ShortName", "R.A").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri month 4 - KLocale::ShortName", "R.T").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri month 5 - KLocale::ShortName", "J.A").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri month 6 - KLocale::ShortName", "J.T").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri month 7 - KLocale::ShortName", "Raj").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Hijri month 8 - KLocale::ShortName", "Sha").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Hijri month 9 - KLocale::ShortName", "Ram").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Hijri month 10 - KLocale::ShortName", "Shw").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Hijri month 11 - KLocale::ShortName", "Qid").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Hijri month 12 - KLocale::ShortName", "Hij").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::LongName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Hijri month 1 - KLocale::LongName Possessive", "of Muharram").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri month 2 - KLocale::LongName Possessive", "of Safar").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri month 3 - KLocale::LongName Possessive", "of Rabi` al-Awal").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri month 4 - KLocale::LongName Possessive", "of Rabi` al-Thaani").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri month 5 - KLocale::LongName Possessive", "of Jumaada al-Awal").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri month 6 - KLocale::LongName Possessive", "of Jumaada al-Thaani").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri month 7 - KLocale::LongName Possessive", "of Rajab").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Hijri month 8 - KLocale::LongName Possessive", "of Sha`ban").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Hijri month 9 - KLocale::LongName Possessive", "of Ramadan").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Hijri month 10 - KLocale::LongName Possessive", "of Shawwal").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Hijri month 11 - KLocale::LongName Possessive", "of Thu al-Qi`dah").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Hijri month 12 - KLocale::LongName Possessive", "of Thu al-Hijjah").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Default to LongName
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Hijri month 1 - KLocale::LongName", "Muharram").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri month 2 - KLocale::LongName", "Safar").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri month 3 - KLocale::LongName", "Rabi` al-Awal").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri month 4 - KLocale::LongName", "Rabi` al-Thaani").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri month 5 - KLocale::LongName", "Jumaada al-Awal").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri month 6 - KLocale::LongName", "Jumaada al-Thaani").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri month 7 - KLocale::LongName", "Rajab").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Hijri month 8 - KLocale::LongName", "Sha`ban").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Hijri month 9 - KLocale::LongName", "Ramadan").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Hijri month 10 - KLocale::LongName", "Shawwal").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Hijri month 11 - KLocale::LongName", "Thu al-Qi`dah").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Hijri month 12 - KLocale::LongName", "Thu al-Hijjah").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString KCalendarSystemIslamicCivilPrivate::weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
|
||||
{
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Hijri weekday 1 - KLocale::NarrowName ", "I").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri weekday 2 - KLocale::NarrowName ", "T").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri weekday 3 - KLocale::NarrowName ", "A").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri weekday 4 - KLocale::NarrowName ", "K").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri weekday 5 - KLocale::NarrowName ", "J").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri weekday 6 - KLocale::NarrowName ", "S").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri weekday 7 - KLocale::NarrowName ", "A").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName || format == KLocale:: ShortNumber) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Hijri weekday 1 - KLocale::ShortName", "Ith").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri weekday 2 - KLocale::ShortName", "Thl").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri weekday 3 - KLocale::ShortName", "Arb").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri weekday 4 - KLocale::ShortName", "Kha").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri weekday 5 - KLocale::ShortName", "Jum").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri weekday 6 - KLocale::ShortName", "Sab").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri weekday 7 - KLocale::ShortName", "Ahd").toString(locale());
|
||||
default: return QString();
|
||||
}
|
||||
}
|
||||
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Hijri weekday 1 - KLocale::LongName", "Yaum al-Ithnain").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Hijri weekday 2 - KLocale::LongName", "Yau al-Thulatha").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Hijri weekday 3 - KLocale::LongName", "Yaum al-Arbi'a").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Hijri weekday 4 - KLocale::LongName", "Yaum al-Khamees").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Hijri weekday 5 - KLocale::LongName", "Yaum al-Jumma").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Hijri weekday 6 - KLocale::LongName", "Yaum al-Sabt").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Hijri weekday 7 - KLocale::LongName", "Yaum al-Ahad").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemIslamicCivil::KCalendarSystemIslamicCivil(const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemIslamicCivilPrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemIslamicCivil::KCalendarSystemIslamicCivil(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemIslamicCivilPrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemIslamicCivil::KCalendarSystemIslamicCivil(KCalendarSystemIslamicCivilPrivate &dd,
|
||||
const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystem(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemIslamicCivil::~KCalendarSystemIslamicCivil()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemIslamicCivil::calendarType() const
|
||||
{
|
||||
return QLatin1String("hijri");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemIslamicCivil::epoch() const
|
||||
{
|
||||
// 16 July 622 in the Julian calendar
|
||||
return QDate::fromJulianDay(1948440);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemIslamicCivil::earliestValidDate() const
|
||||
{
|
||||
return epoch();
|
||||
}
|
||||
|
||||
QDate KCalendarSystemIslamicCivil::latestValidDate() const
|
||||
{
|
||||
// Set to last day of year 9999
|
||||
// Last day of Islamic Civil year 9999 is 9999-12-29
|
||||
return QDate::fromJulianDay(5491751);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystem::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(date);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIslamicCivil::monthName(int month, int year, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(month, year, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIslamicCivil::monthName(const QDate &date, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(date, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIslamicCivil::weekDayName(int weekDay, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(weekDay, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemIslamicCivil::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(date, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isLunar() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isLunisolar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isSolar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
Q_D(const KCalendarSystemIslamicCivil);
|
||||
|
||||
/*
|
||||
The following C++ code is translated from the Lisp code
|
||||
in ``Calendrical Calculations'' by Nachum Dershowitz and
|
||||
Edward M. Reingold, Software---Practice & Experience,
|
||||
vol. 20, no. 9 (September, 1990), pp. 899--928.
|
||||
|
||||
This code is in the public domain, but any use of it
|
||||
should publically acknowledge its source.
|
||||
*/
|
||||
|
||||
// Search forward year by year from approximate year
|
||||
year = (jd - epoch().toJulianDay()) / 355;
|
||||
int testJd;
|
||||
dateToJulianDay(year, 12, d->daysInMonth(year, 12), testJd);
|
||||
while (jd > testJd) {
|
||||
year++;
|
||||
dateToJulianDay(year, 12, d->daysInMonth(year, 12), testJd);
|
||||
}
|
||||
|
||||
// Search forward month by month from Muharram
|
||||
month = 1;
|
||||
dateToJulianDay(year, month, d->daysInMonth(year, month), testJd);
|
||||
while (jd > testJd) {
|
||||
month++;
|
||||
dateToJulianDay(year, month, d->daysInMonth(year, month), testJd);
|
||||
}
|
||||
|
||||
dateToJulianDay(year, month, 1, testJd);
|
||||
day = jd - testJd + 1;
|
||||
|
||||
return true;
|
||||
|
||||
// Alternative implementations
|
||||
|
||||
// More recent editions of "Calendrical Calculations" by Dershowitz & Reingold have a more
|
||||
// efficient direct calculation without recusrion, but this cannot be used due to licensing
|
||||
|
||||
/*
|
||||
Formula from "Explanatory Supplement to the Astronomical Almanac" 2006, derived from Fliegel & Van Flandern 1968
|
||||
int L = jd - epoch().toJulianDay() + 10632;
|
||||
int N = ( L - 1 ) / 10631;
|
||||
L = L - 10631 * N + 354;
|
||||
int J = ( ( 10985 - L ) / 5316 ) x ( ( 50* L ) / 17719 ) + ( L / 5670 ) * ( ( 43 * L ) / 15238 );
|
||||
L = L - ( ( 30 - J ) / 15 ) * ( ( 17719 * J ) / 50 ) - ( J / 16 ) * ( ( 15238 * J ) / 43 ) + 29;
|
||||
year = ( 30 * N ) + J - 30;
|
||||
month = ( 24 * L ) / 709;
|
||||
day = L - ( ( 709 * month ) / 24 );
|
||||
*/
|
||||
|
||||
/*
|
||||
Formula from Fourmilab website
|
||||
jd = Math.floor(jd) + 0.5;
|
||||
year = Math.floor(((30 * (jd - epoch().toJulianDay())) + 10646) / 10631);
|
||||
month = qMin(12, Math.ceil((jd - (29 + islamic_to_jd(year, 1, 1))) / 29.5) + 1);
|
||||
day = (jd - islamic_to_jd(year, month, 1)) + 1;
|
||||
*/
|
||||
}
|
||||
|
||||
bool KCalendarSystemIslamicCivil::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
/*
|
||||
The following C++ code is translated from the Lisp code
|
||||
in ``Calendrical Calculations'' by Nachum Dershowitz and
|
||||
Edward M. Reingold, Software---Practice & Experience,
|
||||
vol. 20, no. 9 (September, 1990), pp. 899--928.
|
||||
|
||||
This code is in the public domain, but any use of it
|
||||
should publically acknowledge its source.
|
||||
*/
|
||||
|
||||
jd = epoch().toJulianDay() - 1 + // days before start of calendar
|
||||
(year - 1) * 354 + // non-leap days in prior years
|
||||
(3 + (11 * year)) / 30 + // leap days in prior years
|
||||
29 * (month - 1) + // days so far...
|
||||
month / 2 + // ...this year
|
||||
day; // days so far this month
|
||||
|
||||
return true;
|
||||
|
||||
// Alternative implementations
|
||||
|
||||
/*
|
||||
Formula from "Explanatory Supplement to the Astronomical Almanac" 2006, derived from Fliegel & Van Flandern 1968
|
||||
jd = ( 3 + ( 11 * year ) ) / 30 + 354 * year + 30 * month - ( month - 1 ) / 2 + day + epoch().toJulianDay() - 385;
|
||||
*/
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es>
|
||||
Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
|
||||
Copyright 2007, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMISLAMICCIVIL_H
|
||||
#define KCALENDARSYSTEMISLAMICCIVIL_H
|
||||
|
||||
#include "kcalendarsystem.h"
|
||||
|
||||
class KCalendarSystemIslamicCivilPrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Islamic Civil calendar implementation.
|
||||
*
|
||||
* The Islamic or Hijri calendar is the traditional calendar used in the Middle
|
||||
* East. This implementation is of the civil calculation that does not take
|
||||
* observed sunset into account and so may vary from actual dates by 1-2 days.
|
||||
*
|
||||
* @b license GNU-LGPL v2+
|
||||
*
|
||||
* @see KLocale,KCalendarSystem
|
||||
*
|
||||
* @author Carlos Moro <cfmoro@correo.uniovi.es>
|
||||
*/
|
||||
class KCalendarSystemIslamicCivil : public KCalendarSystem
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemIslamicCivil(const KLocale *locale = 0);
|
||||
explicit KCalendarSystemIslamicCivil(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemIslamicCivil();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemIslamicCivil(KCalendarSystemIslamicCivilPrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemIslamicCivil)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMISLAMICCIVIL_H
|
|
@ -1,621 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2002-2003 Arash Bijanzadeh and FarsiKDE Project <www.farsikde.org>
|
||||
Contact: Arash Bijanzadeh <a.bijanzadeh@linuxiran.org>
|
||||
Copyright 2007, 2008, 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
This is an implementation of the artithmetic Persian calendar using the
|
||||
Birashk algorithm with adjustments to always be correct in the period 1244
|
||||
and 1530 (1865 to 2152 Gregorian).
|
||||
|
||||
In future this will be replaced with the correct astronomical calendar.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemjalali_p.h"
|
||||
#include "kcalendarsystemprivate_p.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
class KCalendarSystemJalaliPrivate : public KCalendarSystemPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemJalaliPrivate(KCalendarSystemJalali *q);
|
||||
|
||||
virtual ~KCalendarSystemJalaliPrivate();
|
||||
|
||||
// Virtual methods each calendar system must re-implement
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual int monthsInYear(int year) const;
|
||||
virtual int daysInMonth(int year, int month) const;
|
||||
virtual int daysInYear(int year) const;
|
||||
virtual int daysInWeek() const;
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool hasLeapMonths() const;
|
||||
virtual bool hasYearZero() const;
|
||||
virtual int maxDaysInWeek() const;
|
||||
virtual int maxMonthsInYear() const;
|
||||
virtual int earliestValidYear() const;
|
||||
virtual int latestValidYear() const;
|
||||
virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const;
|
||||
virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
|
||||
};
|
||||
|
||||
// Shared d pointer base class definitions
|
||||
|
||||
KCalendarSystemJalaliPrivate::KCalendarSystemJalaliPrivate(KCalendarSystemJalali *q)
|
||||
: KCalendarSystemPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarSystemJalaliPrivate::~KCalendarSystemJalaliPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemJalaliPrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::JalaliCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemJalaliPrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
// Islamic Era (Hijri), Anno Persico.
|
||||
name = i18nc("Calendar Era: Jalali Islamic Era, years > 0, LongFormat", "Anno Persico");
|
||||
shortName = i18nc("Calendar Era: Jalali Islamic Era, years > 0, ShortFormat", "AP");
|
||||
format = i18nc("(kdedt-format) Jalali, AP, full era year format used for %EY, e.g. 2000 AP", "%Ey %EC");
|
||||
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::monthsInYear(int year) const
|
||||
{
|
||||
Q_UNUSED(year)
|
||||
return 12;
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::daysInMonth(int year, int month) const
|
||||
{
|
||||
if (month == 12) {
|
||||
if (isLeapYear(year)) {
|
||||
return 30;
|
||||
} else {
|
||||
return 29;
|
||||
}
|
||||
}
|
||||
|
||||
if (month <= 6) {
|
||||
return 31;
|
||||
}
|
||||
|
||||
return 30;
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::daysInYear(int year) const
|
||||
{
|
||||
if (isLeapYear(year)) {
|
||||
return 366;
|
||||
} else {
|
||||
return 365;
|
||||
}
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::daysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalaliPrivate::isLeapYear(int year) const
|
||||
{
|
||||
// From formilab Public Domain code http://www.fourmilab.ch/documents/calendar/
|
||||
// Use Birashk algorithm as it matches the to/from jd code below
|
||||
|
||||
// Birashk algorithm is incorrect in two years in period AP 1244 to 1531,
|
||||
// 1403/1404 and 1436/1437, and so catch them here first
|
||||
if (year == 1403 || year == 1436) {
|
||||
return true;
|
||||
} else if (year == 1404 || year == 1437) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (year >= 0) {
|
||||
year = year - 474;
|
||||
} else {
|
||||
year = year - 473;
|
||||
}
|
||||
|
||||
if ((((((year % 2820) + 474) + 38) * 682) % 2816) < 682) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalaliPrivate::hasLeapMonths() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalaliPrivate::hasYearZero() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::maxDaysInWeek() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::maxMonthsInYear() const
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::earliestValidYear() const
|
||||
{
|
||||
return 1244;
|
||||
}
|
||||
|
||||
int KCalendarSystemJalaliPrivate::latestValidYear() const
|
||||
{
|
||||
return 1530;
|
||||
}
|
||||
|
||||
QString KCalendarSystemJalaliPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
|
||||
{
|
||||
Q_UNUSED(year);
|
||||
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Jalali month 1 - KLocale::NarrowName", "F").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali month 2 - KLocale::NarrowName", "O").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali month 3 - KLocale::NarrowName", "K").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali month 4 - KLocale::NarrowName", "T").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali month 5 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali month 6 - KLocale::NarrowName", "S").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali month 7 - KLocale::NarrowName", "M").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Jalali month 8 - KLocale::NarrowName", "A").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Jalali month 9 - KLocale::NarrowName", "A").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Jalali month 10 - KLocale::NarrowName", "D").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Jalali month 11 - KLocale::NarrowName", "B").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Jalali month 12 - KLocale::NarrowName", "E").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Jalali month 1 - KLocale::ShortName Possessive", "of Far").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali month 2 - KLocale::ShortName Possessive", "of Ord").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali month 3 - KLocale::ShortName Possessive", "of Kho").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali month 4 - KLocale::ShortName Possessive", "of Tir").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali month 5 - KLocale::ShortName Possessive", "of Mor").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali month 6 - KLocale::ShortName Possessive", "of Sha").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali month 7 - KLocale::ShortName Possessive", "of Meh").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Jalali month 8 - KLocale::ShortName Possessive", "of Aba").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Jalali month 9 - KLocale::ShortName Possessive", "of Aza").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Jalali month 10 - KLocale::ShortName Possessive", "of Dei").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Jalali month 11 - KLocale::ShortName Possessive", "of Bah").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Jalali month 12 - KLocale::ShortName Possessive", "of Esf").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName && !possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Jalali month 1 - KLocale::ShortName", "Far").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali month 2 - KLocale::ShortName", "Ord").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali month 3 - KLocale::ShortName", "Kho").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali month 4 - KLocale::ShortName", "Tir").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali month 5 - KLocale::ShortName", "Mor").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali month 6 - KLocale::ShortName", "Sha").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali month 7 - KLocale::ShortName", "Meh").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Jalali month 8 - KLocale::ShortName", "Aba").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Jalali month 9 - KLocale::ShortName", "Aza").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Jalali month 10 - KLocale::ShortName", "Dei").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Jalali month 11 - KLocale::ShortName", "Bah").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Jalali month 12 - KLocale::ShortName", "Esf").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::LongName && possessive) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Jalali month 1 - KLocale::LongName Possessive", "of Farvardin").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali month 2 - KLocale::LongName Possessive", "of Ordibehesht").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali month 3 - KLocale::LongName Possessive", "of Khordad").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali month 4 - KLocale::LongName Possessive", "of Tir").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali month 5 - KLocale::LongName Possessive", "of Mordad").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali month 6 - KLocale::LongName Possessive", "of Shahrivar").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali month 7 - KLocale::LongName Possessive", "of Mehr").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Jalali month 8 - KLocale::LongName Possessive", "of Aban").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Jalali month 9 - KLocale::LongName Possessive", "of Azar").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Jalali month 10 - KLocale::LongName Possessive", "of Dei").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Jalali month 11 - KLocale::LongName Possessive", "of Bahman").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Jalali month 12 - KLocale::LongName Possessive", "of Esfand").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
// Default to LongName
|
||||
switch (month) {
|
||||
case 1:
|
||||
return ki18nc("Jalali month 1 - KLocale::LongName", "Farvardin").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali month 2 - KLocale::LongName", "Ordibehesht").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali month 3 - KLocale::LongName", "Khordad").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali month 4 - KLocale::LongName", "Tir").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali month 5 - KLocale::LongName", "Mordad").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali month 6 - KLocale::LongName", "Shahrivar").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali month 7 - KLocale::LongName", "Mehr").toString(locale());
|
||||
case 8:
|
||||
return ki18nc("Jalali month 8 - KLocale::LongName", "Aban").toString(locale());
|
||||
case 9:
|
||||
return ki18nc("Jalali month 9 - KLocale::LongName", "Azar").toString(locale());
|
||||
case 10:
|
||||
return ki18nc("Jalali month 10 - KLocale::LongName", "Dei").toString(locale());
|
||||
case 11:
|
||||
return ki18nc("Jalali month 11 - KLocale::LongName", "Bahman").toString(locale());
|
||||
case 12:
|
||||
return ki18nc("Jalali month 12 - KLocale::LongName", "Esfand").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString KCalendarSystemJalaliPrivate::weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
|
||||
{
|
||||
if (format == KLocale::NarrowName) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Jalali weekday 1 - KLocale::NarrowName ", "2").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali weekday 2 - KLocale::NarrowName ", "3").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali weekday 3 - KLocale::NarrowName ", "4").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali weekday 4 - KLocale::NarrowName ", "5").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali weekday 5 - KLocale::NarrowName ", "J").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali weekday 6 - KLocale::NarrowName ", "S").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali weekday 7 - KLocale::NarrowName ", "1").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (format == KLocale::ShortName || format == KLocale:: ShortNumber) {
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Jalali weekday 1 - KLocale::ShortName", "2sh").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali weekday 2 - KLocale::ShortName", "3sh").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali weekday 3 - KLocale::ShortName", "4sh").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali weekday 4 - KLocale::ShortName", "5sh").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali weekday 5 - KLocale::ShortName", "Jom").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali weekday 6 - KLocale::ShortName", "Shn").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali weekday 7 - KLocale::ShortName", "1sh").toString(locale());
|
||||
default: return QString();
|
||||
}
|
||||
}
|
||||
|
||||
switch (weekDay) {
|
||||
case 1:
|
||||
return ki18nc("Jalali weekday 1 - KLocale::LongName", "Do shanbe").toString(locale());
|
||||
case 2:
|
||||
return ki18nc("Jalali weekday 2 - KLocale::LongName", "Se shanbe").toString(locale());
|
||||
case 3:
|
||||
return ki18nc("Jalali weekday 3 - KLocale::LongName", "Chahar shanbe").toString(locale());
|
||||
case 4:
|
||||
return ki18nc("Jalali weekday 4 - KLocale::LongName", "Panj shanbe").toString(locale());
|
||||
case 5:
|
||||
return ki18nc("Jalali weekday 5 - KLocale::LongName", "Jumee").toString(locale());
|
||||
case 6:
|
||||
return ki18nc("Jalali weekday 6 - KLocale::LongName", "Shanbe").toString(locale());
|
||||
case 7:
|
||||
return ki18nc("Jalali weekday 7 - KLocale::LongName", "Yek-shanbe").toString(locale());
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemJalali::KCalendarSystemJalali(const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemJalaliPrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemJalali::KCalendarSystemJalali(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystem(*new KCalendarSystemJalaliPrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemJalali::KCalendarSystemJalali(KCalendarSystemJalaliPrivate &dd,
|
||||
const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystem(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemJalali::~KCalendarSystemJalali()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemJalali::calendarType() const
|
||||
{
|
||||
return QLatin1String("jalali");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemJalali::epoch() const
|
||||
{
|
||||
// 19 March 622 in the Julian calendar
|
||||
return QDate::fromJulianDay(1948321);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemJalali::earliestValidDate() const
|
||||
{
|
||||
// Using the Birashk formula which is accurate in period AP 1244 to 1530 (AD 1865 to 2152)
|
||||
// 1244-01-01 Jalali 1865-03-21 Gregorian
|
||||
return QDate::fromJulianDay(2402317);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemJalali::latestValidDate() const
|
||||
{
|
||||
// Using the Birashk formula which is accurate in period AP 1244 to 1530 (AD 1865 to 2152)
|
||||
// 1530-12-29 Jalali 2152-03-19 Gregorian
|
||||
return QDate::fromJulianDay(2507140);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystem::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystem::isLeapYear(date);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJalali::monthName(int month, int year, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(month, year, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJalali::monthName(const QDate &date, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::monthName(date, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJalali::weekDayName(int weekDay, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(weekDay, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJalali::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystem::weekDayName(date, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isLunar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isLunisolar() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isSolar() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
// Birashk algorithm is incorrect in two years in period AP 1244 to 1531.
|
||||
// This results in a leap day being added to the end of 1404 instead of 1403
|
||||
// and to the end of 1437 instead of 1436. Check for these dates first and
|
||||
// return accordingly. Relies on later use of dateToJulianDay() to correctly
|
||||
// calculate firstDayOfYear in 1404 and 1437, so no other adjustments needed.
|
||||
if (jd == 2460755) {
|
||||
year = 1403;
|
||||
month = 12;
|
||||
day = 30;
|
||||
return true;
|
||||
}
|
||||
if (jd == 2472808) {
|
||||
year = 1436;
|
||||
month = 12;
|
||||
day = 30;
|
||||
return true;
|
||||
}
|
||||
|
||||
// From original KDE3 code, source unknown? Unable to contact author or committer to confirm
|
||||
// Matches Fermilab code, EMACS and D&R so check for PD source, likely Birashk's book
|
||||
|
||||
int jdCycleStart;
|
||||
int daysSinceCycleStart;
|
||||
int cycle;
|
||||
int dayInCycle;
|
||||
int yearInCycle;
|
||||
dateToJulianDay(475, 1, 1, jdCycleStart);
|
||||
daysSinceCycleStart = jd - jdCycleStart;
|
||||
cycle = daysSinceCycleStart / 1029983;
|
||||
dayInCycle = daysSinceCycleStart % 1029983;
|
||||
if (dayInCycle == 1029982) {
|
||||
yearInCycle = 2820;
|
||||
} else {
|
||||
int aux1 = dayInCycle / 366;
|
||||
int aux2 = dayInCycle % 366;
|
||||
yearInCycle = (((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1;
|
||||
}
|
||||
year = yearInCycle + (2820 * cycle) + 474;
|
||||
if (year <= 0) {
|
||||
year = year - 1;
|
||||
}
|
||||
|
||||
int firstDayOfYear;
|
||||
dateToJulianDay(year, 1, 1, firstDayOfYear);
|
||||
int dayinYear = jd - firstDayOfYear + 1;
|
||||
if (dayinYear <= 186) {
|
||||
month = ((dayinYear - 1) / 31) + 1;
|
||||
day = dayinYear - ((month - 1) * 31);
|
||||
} else {
|
||||
month = ((dayinYear - 7) / 30) + 1;
|
||||
day = dayinYear - ((month - 1) * 30) - 6;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJalali::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
Q_D(const KCalendarSystemJalali);
|
||||
|
||||
// Birashk algorithm is incorrect in two years in period AP 1244 to 1531.
|
||||
// This results in a leap day being added to the end of 1404 instead of 1403
|
||||
// and to the end of 1437 instead of 1436. Thus all dates in 1404 and 1437
|
||||
// are off by 1 JD. Check for these dates first and adjust accordingly.
|
||||
if (year == 1403 && month == 12 && day == 30) {
|
||||
jd = 2460755;
|
||||
return true;
|
||||
}
|
||||
if (year == 1436 && month == 12 && day == 30) {
|
||||
jd = 2472808;
|
||||
return true;
|
||||
}
|
||||
if (year == 1404 || year == 1437) {
|
||||
if (month < 12 && day + 1 > d->daysInMonth(year, month)) {
|
||||
day = 1;
|
||||
month = month + 1;
|
||||
} else {
|
||||
day = day + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// From original KDE3 code, source unknown? Unable to contact author or committer to confirm
|
||||
// Matches Fermilab code, EMACS and D&R so check for PD source, likely Birashk's book
|
||||
int epbase;
|
||||
long epyear;
|
||||
long monthDays;
|
||||
|
||||
if (year >= 0) {
|
||||
epbase = year - 474;
|
||||
} else {
|
||||
epbase = year - 473;
|
||||
}
|
||||
|
||||
epyear = 474 + (epbase % 2820);
|
||||
|
||||
if (month <= 7) {
|
||||
monthDays = (month - 1) * 31;
|
||||
} else {
|
||||
monthDays = ((month - 1) * 30) + 6;
|
||||
}
|
||||
|
||||
jd = (epoch().toJulianDay() - 1) + // days before epoch
|
||||
(epyear - 1) * 365 + // normal days in previous years
|
||||
(((epyear * 682) - 110) / 2816) + // leap days in previous years
|
||||
(epbase / 2820) * 1029983 +
|
||||
monthDays + // days in previous months this year
|
||||
day; // days in this month
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2002-2003 Arash Bijanzadeh and FarsiKDE Project <www.farsikde.org>
|
||||
Contact: Arash Bijanzadeh <a.bijanzadeh@linuxiran.org>
|
||||
Copyright 2007, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMJALALI_H
|
||||
#define KCALENDARSYSTEMJALALI_H
|
||||
|
||||
#include "kcalendarsystem.h"
|
||||
|
||||
class KCalendarSystemJalaliPrivate;
|
||||
|
||||
/**
|
||||
Jalali calendar type implementation
|
||||
*/
|
||||
class KCalendarSystemJalali : public KCalendarSystem
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemJalali(const KLocale * locale = 0);
|
||||
explicit KCalendarSystemJalali(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemJalali();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemJalali(KCalendarSystemJalaliPrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemJalali)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMJALALI_H
|
|
@ -1,229 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemjapanese_p.h"
|
||||
#include "kcalendarsystemgregorianprivate_p.h"
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "klocale.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
//Reuse the Gregorian private implementation
|
||||
class KCalendarSystemJapanesePrivate : public KCalendarSystemGregorianPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemJapanesePrivate(KCalendarSystemJapanese *q);
|
||||
virtual ~KCalendarSystemJapanesePrivate();
|
||||
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual int earliestValidYear() const;
|
||||
};
|
||||
|
||||
//Override only a few of the Gregorian private methods
|
||||
|
||||
KCalendarSystemJapanesePrivate::KCalendarSystemJapanesePrivate(KCalendarSystemJapanese *q)
|
||||
: KCalendarSystemGregorianPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarSystemJapanesePrivate::~KCalendarSystemJapanesePrivate()
|
||||
{
|
||||
}
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemJapanesePrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::JapaneseCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemJapanesePrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
|
||||
// Nengō, Only do most recent for now, use AD for the rest.
|
||||
// Feel free to add more, but have mercy on the translators :-)
|
||||
|
||||
name = i18nc("Calendar Era: Gregorian Christian Era, years > 0, LongFormat", "Anno Domini");
|
||||
shortName = i18nc("Calendar Era: Gregorian Christian Era, years > 0, ShortFormat", "AD");
|
||||
format = i18nc("(kdedt-format) Gregorian, AD, full era year format used for %EY, e.g. 2000 AD", "%Ey %EC");
|
||||
addEra('+', 1, q->epoch(), 1, QDate(1868, 9, 7), name, shortName, format);
|
||||
|
||||
name = i18nc("Calendar Era: Japanese Nengō, Meiji Era, LongFormat", "Meiji");
|
||||
shortName = name;
|
||||
format = i18nc("(kdedt-format) Japanese, Meiji, full era year format used for %EY, year = 1, e.g. Meiji 1", "%EC Gannen");
|
||||
addEra('+', 1, QDate(1868, 9, 8), 1868, QDate(1868, 12, 31), name, shortName, format);
|
||||
format = i18nc("(kdedt-format) Japanese, Meiji, full era year format used for %EY, year > 1, e.g. Meiji 22", "%EC %Ey");
|
||||
addEra('+', 2, QDate(1869, 1, 1), 1869, QDate(1912, 7, 29), name, shortName, format);
|
||||
|
||||
name = i18nc("Calendar Era: Japanese Nengō, Taishō Era, LongFormat", "Taishō");
|
||||
shortName = name;
|
||||
format = i18nc("(kdedt-format) Japanese, Taishō, full era year format used for %EY, year = 1, e.g. Taishō 1", "%EC Gannen");
|
||||
addEra('+', 1, QDate(1912, 7, 30), 1912, QDate(1912, 12, 31), name, shortName, format);
|
||||
format = i18nc("(kdedt-format) Japanese, Taishō, full era year format used for %EY, year > 1, e.g. Taishō 22", "%EC %Ey");
|
||||
addEra('+', 2, QDate(1913, 1, 1), 1913, QDate(1926, 12, 24), name, shortName, format);
|
||||
|
||||
name = i18nc("Calendar Era: Japanese Nengō, Shōwa Era, LongFormat", "Shōwa");
|
||||
shortName = name;
|
||||
format = i18nc("(kdedt-format) Japanese, Shōwa, full era year format used for %EY, year = 1, e.g. Shōwa 1", "%EC Gannen");
|
||||
addEra('+', 1, QDate(1926, 12, 25), 1926, QDate(1926, 12, 31), name, shortName, format);
|
||||
format = i18nc("(kdedt-format) Japanese, Shōwa, full era year format used for %EY, year > 1, e.g. Shōwa 22", "%EC %Ey");
|
||||
addEra('+', 2, QDate(1927, 1, 1), 1927, QDate(1989, 1, 7), name, shortName, format);
|
||||
|
||||
name = i18nc("Calendar Era: Japanese Nengō, Heisei Era, LongFormat", "Heisei");
|
||||
shortName = name;
|
||||
format = i18nc("(kdedt-format) Japanese, Heisei, full era year format used for %EY, year = 1, e.g. Heisei 1", "%EC Gannen");
|
||||
addEra('+', 1, QDate(1989, 1, 8), 1989, QDate(1989, 12, 31), name, shortName, format);
|
||||
format = i18nc("(kdedt-format) Japanese, Heisei, full era year format used for %EY, year > 1, e.g. Heisei 22", "%EC %Ey");
|
||||
addEra('+', 2, QDate(1990, 1, 1), 1990, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
int KCalendarSystemJapanesePrivate::earliestValidYear() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemJapanese::KCalendarSystemJapanese(const KLocale *locale)
|
||||
: KCalendarSystemGregorian(*new KCalendarSystemJapanesePrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemJapanese::KCalendarSystemJapanese(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemGregorian(*new KCalendarSystemJapanesePrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemJapanese::KCalendarSystemJapanese(KCalendarSystemJapanesePrivate &dd,
|
||||
const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemGregorian(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemJapanese::~KCalendarSystemJapanese()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemJapanese::calendarType() const
|
||||
{
|
||||
return QLatin1String("japanese");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemJapanese::epoch() const
|
||||
{
|
||||
// 0001-01-01 Gregorian for now
|
||||
return QDate::fromJulianDay(1721426);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemJapanese::earliestValidDate() const
|
||||
{
|
||||
// 0001-01-01 Gregorian for now
|
||||
return QDate::fromJulianDay(1721426);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemJapanese::latestValidDate() const
|
||||
{
|
||||
// Set to last day of year 9999 until confirm date formats & widgets support > 9999
|
||||
// 9999-12-31 Gregorian
|
||||
return QDate::fromJulianDay(5373484);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLeapYear(date);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJapanese::monthName(int month, int year, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::monthName(month, year, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJapanese::monthName(const QDate &date, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::monthName(date, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJapanese::weekDayName(int weekDay, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::weekDayName(weekDay, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemJapanese::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::weekDayName(date, format);
|
||||
}
|
||||
|
||||
int KCalendarSystemJapanese::yearStringToInteger(const QString &sNum, int &iLength) const
|
||||
{
|
||||
QString gannen = i18nc("Japanese year 1 of era", "Gannen");
|
||||
if (sNum.startsWith(gannen, Qt::CaseInsensitive)) {
|
||||
iLength = gannen.length();
|
||||
return 1;
|
||||
} else {
|
||||
return KCalendarSystemGregorian::yearStringToInteger(sNum, iLength);
|
||||
}
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isLunar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLunar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isLunisolar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLunisolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isSolar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isSolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
return KCalendarSystemGregorian::julianDayToDate(jd, year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemJapanese::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
return KCalendarSystemGregorian::dateToJulianDay(year, month, day, jd);
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMJAPANESE_H
|
||||
#define KCALENDARSYSTEMJAPANESE_H
|
||||
|
||||
#include "kcalendarsystemgregorian_p.h"
|
||||
|
||||
class KCalendarSystemJapanesePrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Japanese calendar implementation which is the Gregorian calendar
|
||||
* but using the Japanese Era (Nengô) instead of the Christian/Common Era
|
||||
*
|
||||
* @b license GNU-LGPL v.2 or later
|
||||
*
|
||||
* @see KLocale,KCalendarSystem
|
||||
*
|
||||
* @author John Layt <john@layt.net>
|
||||
*/
|
||||
class KCalendarSystemJapanese: public KCalendarSystemGregorian
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemJapanese(const KLocale *locale = 0);
|
||||
explicit KCalendarSystemJapanese(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemJapanese();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemJapanese(KCalendarSystemJapanesePrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemJapanese)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMJAPANESE_H
|
|
@ -1,195 +0,0 @@
|
|||
/*
|
||||
Copyright 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemminguo_p.h"
|
||||
#include "kcalendarsystemgregorianprivate_p.h"
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "klocale.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
//Reuse the Gregorian private implementation
|
||||
class KCalendarSystemMinguoPrivate : public KCalendarSystemGregorianPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemMinguoPrivate(KCalendarSystemMinguo *q);
|
||||
virtual ~KCalendarSystemMinguoPrivate();
|
||||
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual int earliestValidYear() const;
|
||||
};
|
||||
|
||||
//Override only a few of the Gregorian private methods
|
||||
|
||||
KCalendarSystemMinguoPrivate::KCalendarSystemMinguoPrivate(KCalendarSystemMinguo *q)
|
||||
: KCalendarSystemGregorianPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarSystemMinguoPrivate::~KCalendarSystemMinguoPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemMinguoPrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::MinguoCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemMinguoPrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
|
||||
name = i18nc("Calendar Era: Taiwan Republic of China Era, years > 0, LongFormat", "Republic of China Era");
|
||||
shortName = i18nc("Calendar Era: Taiwan Republic of China Era, years > 0, ShortFormat", "ROC");
|
||||
format = i18nc("(kdedt-format) Taiwan, ROC, full era year format used for %EY, e.g. ROC 99", "%EC %Ey");
|
||||
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguoPrivate::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystemGregorianPrivate::isLeapYear(year + 1911);
|
||||
}
|
||||
|
||||
int KCalendarSystemMinguoPrivate::earliestValidYear() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemMinguo::KCalendarSystemMinguo(const KLocale *locale)
|
||||
: KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemMinguo::KCalendarSystemMinguo(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemMinguo::KCalendarSystemMinguo(KCalendarSystemMinguoPrivate &dd,
|
||||
const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemGregorian(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemMinguo::~KCalendarSystemMinguo()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemMinguo::calendarType() const
|
||||
{
|
||||
return QLatin1String("minguo");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemMinguo::epoch() const
|
||||
{
|
||||
// 0001-01-01 = 1912-01-01 AD Gregorian
|
||||
return QDate::fromJulianDay(2419403);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemMinguo::earliestValidDate() const
|
||||
{
|
||||
return epoch();
|
||||
}
|
||||
|
||||
QDate KCalendarSystemMinguo::latestValidDate() const
|
||||
{
|
||||
// Set to last day of year 9999 until confirm date formats & widgets support > 9999
|
||||
// 9999-12-31 = 11910-12-31 AD Gregorian
|
||||
return QDate::fromJulianDay(6071462);
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLeapYear(date);
|
||||
}
|
||||
|
||||
QString KCalendarSystemMinguo::monthName(int month, int year, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::monthName(month, year, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemMinguo::monthName(const QDate &date, MonthNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::monthName(date, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemMinguo::weekDayName(int weekDay, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::weekDayName(weekDay, format);
|
||||
}
|
||||
|
||||
QString KCalendarSystemMinguo::weekDayName(const QDate &date, WeekDayNameFormat format) const
|
||||
{
|
||||
return KCalendarSystemGregorian::weekDayName(date, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isLunar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLunar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isLunisolar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLunisolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isSolar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isSolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
bool result = KCalendarSystemGregorian::julianDayToDate(jd, year, month, day);
|
||||
year = year - 1911;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool KCalendarSystemMinguo::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
return KCalendarSystemGregorian::dateToJulianDay(year + 1911, month, day, jd);
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
Copyright 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMMINGUO_H
|
||||
#define KCALENDARSYSTEMMINGUO_H
|
||||
|
||||
#include "kcalendarsystemgregorian_p.h"
|
||||
|
||||
class KCalendarSystemMinguoPrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Minguo / Taiwanese / Republic of China calendar implementation
|
||||
* which is the Gregorian calendar but using a different Epoch
|
||||
*
|
||||
* @b license GNU-LGPL v.2 or later
|
||||
*
|
||||
* @see KLocale,KCalendarSystem
|
||||
*
|
||||
* @author John Layt <john@layt.net>
|
||||
*/
|
||||
class KCalendarSystemMinguo: public KCalendarSystemGregorian
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemMinguo(const KLocale *locale = 0);
|
||||
explicit KCalendarSystemMinguo(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemMinguo();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const;
|
||||
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
|
||||
|
||||
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const;
|
||||
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemMinguo(KCalendarSystemMinguoPrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemMinguo)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMMINGUO_H
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
Copyright 2009, 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kcalendarsystemthai_p.h"
|
||||
#include "kcalendarsystemgregorianprivate_p.h"
|
||||
|
||||
#include "kdebug.h"
|
||||
#include "klocale.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
//Reuse the Gregorian private implementation
|
||||
class KCalendarSystemThaiPrivate : public KCalendarSystemGregorianPrivate
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemThaiPrivate(KCalendarSystemThai *q);
|
||||
virtual ~KCalendarSystemThaiPrivate();
|
||||
|
||||
virtual KLocale::CalendarSystem calendarSystem() const;
|
||||
virtual void loadDefaultEraList();
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool hasYearZero() const;
|
||||
virtual int earliestValidYear() const;
|
||||
};
|
||||
|
||||
//Override only a few of the Gregorian private methods
|
||||
|
||||
KCalendarSystemThaiPrivate::KCalendarSystemThaiPrivate(KCalendarSystemThai *q)
|
||||
: KCalendarSystemGregorianPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
KCalendarSystemThaiPrivate::~KCalendarSystemThaiPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
KLocale::CalendarSystem KCalendarSystemThaiPrivate::calendarSystem() const
|
||||
{
|
||||
return KLocale::ThaiCalendar;
|
||||
}
|
||||
|
||||
void KCalendarSystemThaiPrivate::loadDefaultEraList()
|
||||
{
|
||||
QString name, shortName, format;
|
||||
|
||||
name = i18nc("Calendar Era: Thai Buddhist Era, years > 0, LongFormat", "Buddhist Era");
|
||||
shortName = i18nc("Calendar Era: Thai Buddhist Era, years > 0, ShortFormat", "BE");
|
||||
format = i18nc("(kdedt-format) Thai, BE, full era year format used for %EY, e.g. 2000 BE", "%Ey %EC");
|
||||
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
|
||||
}
|
||||
|
||||
bool KCalendarSystemThaiPrivate::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystemGregorianPrivate::isLeapYear(year - 543);
|
||||
}
|
||||
|
||||
bool KCalendarSystemThaiPrivate::hasYearZero() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int KCalendarSystemThaiPrivate::earliestValidYear() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
KCalendarSystemThai::KCalendarSystemThai(const KLocale *locale)
|
||||
: KCalendarSystemGregorian(*new KCalendarSystemThaiPrivate(this), KSharedConfig::Ptr(), locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemThai::KCalendarSystemThai(const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemGregorian(*new KCalendarSystemThaiPrivate(this), config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemThai::KCalendarSystemThai(KCalendarSystemThaiPrivate &dd,
|
||||
const KSharedConfig::Ptr config, const KLocale *locale)
|
||||
: KCalendarSystemGregorian(dd, config, locale)
|
||||
{
|
||||
d_ptr->loadConfig(calendarType());
|
||||
}
|
||||
|
||||
KCalendarSystemThai::~KCalendarSystemThai()
|
||||
{
|
||||
}
|
||||
|
||||
QString KCalendarSystemThai::calendarType() const
|
||||
{
|
||||
return QLatin1String("thai");
|
||||
}
|
||||
|
||||
QDate KCalendarSystemThai::epoch() const
|
||||
{
|
||||
// 0000-01-01 = 0544-01-01 BC Gregorian = 0544-01-07 BC Julian
|
||||
return QDate::fromJulianDay(1522734);
|
||||
}
|
||||
|
||||
QDate KCalendarSystemThai::earliestValidDate() const
|
||||
{
|
||||
return epoch();
|
||||
}
|
||||
|
||||
QDate KCalendarSystemThai::latestValidDate() const
|
||||
{
|
||||
// Set to last day of year 9999 until confirm date formats & widgets support > 9999
|
||||
// 9999-12-31 = 9456-12-31 AD Gregorian
|
||||
return QDate::fromJulianDay(5175158);
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isValid(int year, int month, int day) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isValid(year, month, day);
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isValid(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isValid(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isLeapYear(int year) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLeapYear(year);
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isLeapYear(const QDate &date) const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLeapYear(date);
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isLunar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLunar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isLunisolar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isLunisolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isSolar() const
|
||||
{
|
||||
return KCalendarSystemGregorian::isSolar();
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::isProleptic() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::julianDayToDate(int jd, int &year, int &month, int &day) const
|
||||
{
|
||||
bool result = KCalendarSystemGregorian::julianDayToDate(jd, year, month, day);
|
||||
year = year + 543;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool KCalendarSystemThai::dateToJulianDay(int year, int month, int day, int &jd) const
|
||||
{
|
||||
return KCalendarSystemGregorian::dateToJulianDay(year - 543, month, day, jd);
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
Copyright 2010 John Layt <john@layt.net>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef KCALENDARSYSTEMTHAI_H
|
||||
#define KCALENDARSYSTEMTHAI_H
|
||||
|
||||
#include "kcalendarsystemgregorian_p.h"
|
||||
|
||||
class KCalendarSystemThaiPrivate;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* This is the Thai calendar implementation which is the Gregorian calendar
|
||||
* but using a different Epoch
|
||||
*
|
||||
* @b license GNU-LGPL v.2 or later
|
||||
*
|
||||
* @see KLocale,KCalendarSystem
|
||||
*
|
||||
* @author John Layt <john@layt.net>
|
||||
*/
|
||||
class KCalendarSystemThai: public KCalendarSystemGregorian
|
||||
{
|
||||
public:
|
||||
explicit KCalendarSystemThai(const KLocale *locale = 0);
|
||||
explicit KCalendarSystemThai(const KSharedConfig::Ptr config, const KLocale *locale = 0);
|
||||
virtual ~KCalendarSystemThai();
|
||||
|
||||
virtual QString calendarType() const;
|
||||
|
||||
virtual QDate epoch() const;
|
||||
virtual QDate earliestValidDate() const;
|
||||
virtual QDate latestValidDate() const;
|
||||
virtual bool isValid(int year, int month, int day) const;
|
||||
virtual bool isValid(const QDate &date) const;
|
||||
|
||||
virtual bool isLeapYear(int year) const;
|
||||
virtual bool isLeapYear(const QDate &date) const;
|
||||
|
||||
virtual bool isLunar() const;
|
||||
virtual bool isLunisolar() const;
|
||||
virtual bool isSolar() const;
|
||||
virtual bool isProleptic() const;
|
||||
|
||||
protected:
|
||||
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const;
|
||||
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const;
|
||||
KCalendarSystemThai(KCalendarSystemThaiPrivate &dd,
|
||||
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
|
||||
const KLocale *locale = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(KCalendarSystemThai)
|
||||
};
|
||||
|
||||
#endif // KCALENDARSYSTEMTHAI_H
|
|
@ -318,7 +318,7 @@ bool KTimeZone::isValid() const
|
|||
}
|
||||
// any other check would be way too expensive (e.g. parsing the time zone file to verify it is
|
||||
// valid) but the check bellow will make sure KTimeZone("foo") is not valid and (possibly) mark
|
||||
// no longer existing time zones (due to system tzdata file changes) as invalid
|
||||
// no longer existing time zones (due to system tzdata files removal) as invalid
|
||||
return QFile::exists(zoneinfoDir() + QDir::separator() + d->name);
|
||||
}
|
||||
|
||||
|
|
|
@ -563,29 +563,9 @@ public:
|
|||
* @see calendarSystem()
|
||||
*/
|
||||
enum CalendarSystem {
|
||||
QDateCalendar = 1, /**< KDE Default, hybrid of Gregorian and Julian as used by QDate */
|
||||
//BahaiCalendar = 2, /**< Baha'i Calendar */
|
||||
//BuddhistLunarCalendar = 3, /**< Buddhist Lunar Calendar*/
|
||||
//ChineseCalendar = 4, /**< Chinese Calendar */
|
||||
CopticCalendar = 5, /**< Coptic Calendar as used Coptic Church and some parts of Egypt */
|
||||
EthiopianCalendar = 6, /**< Ethiopian Calendar, aka Ethiopic Calendar */
|
||||
//EthiopianAmeteAlemCalendar = 7, /**< Ethiopian Amete Alem version, aka Ethiopic Amete Alem */
|
||||
GregorianCalendar = 8, /**< Gregorian Calendar, pure proleptic implementation */
|
||||
HebrewCalendar = 9, /**< Hebrew Calendar, aka Jewish Calendar */
|
||||
//HinduCalendar = 10, /**< Hindu Lunar Calendar */
|
||||
//IslamicLunarCalendar = 11, /**< Islamic Lunar Calendar */
|
||||
IslamicCivilCalendar = 12, /**< Islamic Civil Calendar, aka Hijri, not the Lunar Calendar */
|
||||
//IslamicUmAlQuraCalendar = 13, /**< Islamic Lunar Calendar, Um Al Qura varient used in Saudi Arabia */
|
||||
IndianNationalCalendar = 14, /**< Indian National Calendar, not the Lunar Calendar */
|
||||
//Iso8601Calendar = 15, /**< ISO 8601 Standard Calendar */
|
||||
JalaliCalendar = 16, /**< Jalali Calendar, aka Persian or Iranian, also used in Afghanistan */
|
||||
//JalaliBirashkCalendar = 17, /**< Jalali Calendar, Birashk Algorythm variant */
|
||||
//Jalali33YearCalendar = 18, /**< Jalali Calendar, 33 Year cycle variant */
|
||||
JapaneseCalendar= 19, /**< Japanese Calendar, Gregorian calculation using Japanese Era (Nengô) */
|
||||
//JucheCalendar = 20, /**< Juche Calendar, used in North Korea */
|
||||
JulianCalendar = 21, /**< Julian Calendar, as used in Orthodox Churches */
|
||||
MinguoCalendar= 22, /**< Minguo Calendar, aka ROC, Republic of China or Taiwanese */
|
||||
ThaiCalendar = 23 /**< Thai Calendar, aka Buddhist or Thai Buddhist */
|
||||
QDateCalendar = 1, /**< KDE Default, hybrid of Gregorian and Julian as used by QDate */
|
||||
GregorianCalendar = 2, /**< Gregorian Calendar, pure proleptic implementation */
|
||||
JulianCalendar = 3 /**< Julian Calendar, as used in Orthodox Churches */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,14 +40,6 @@ QTEST_KDEMAIN_CORE_WITH_COMPONENTNAME(KCalendarTest, "kdecalendarsystems" /*so t
|
|||
void KCalendarTest::testTypes()
|
||||
{
|
||||
const KCalendarSystem *calendar;
|
||||
calendar = KCalendarSystem::create("coptic");
|
||||
QCOMPARE(calendar->calendarType(), QString("coptic"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::CopticCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("ethiopian");
|
||||
QCOMPARE(calendar->calendarType(), QString("ethiopian"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::EthiopianCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("gregorian");
|
||||
QCOMPARE(calendar->calendarType(), QString("gregorian"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::QDateCalendar);
|
||||
|
@ -56,38 +48,10 @@ void KCalendarTest::testTypes()
|
|||
QCOMPARE(calendar->calendarType(), QString("gregorian-proleptic"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::GregorianCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("hebrew");
|
||||
QCOMPARE(calendar->calendarType(), QString("hebrew"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::HebrewCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("hijri");
|
||||
QCOMPARE(calendar->calendarType(), QString("hijri"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::IslamicCivilCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("indian-national");
|
||||
QCOMPARE(calendar->calendarType(), QString("indian-national"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::IndianNationalCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("jalali");
|
||||
QCOMPARE(calendar->calendarType(), QString("jalali"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::JalaliCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("japanese");
|
||||
QCOMPARE(calendar->calendarType(), QString("japanese"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::JapaneseCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("julian");
|
||||
QCOMPARE(calendar->calendarType(), QString("julian"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::JulianCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("minguo");
|
||||
QCOMPARE(calendar->calendarType(), QString("minguo"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::MinguoCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("thai");
|
||||
QCOMPARE(calendar->calendarType(), QString("thai"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::ThaiCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create("invalid");
|
||||
QCOMPARE(calendar->calendarType(), QString("gregorian"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::QDateCalendar);
|
||||
|
@ -101,106 +65,34 @@ void KCalendarTest::testTypes()
|
|||
QCOMPARE(calendar->calendarType(), QString("gregorian"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::QDateCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::CopticCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("coptic"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::CopticCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::EthiopianCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("ethiopian"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::EthiopianCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::GregorianCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("gregorian-proleptic"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::GregorianCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::HebrewCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("hebrew"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::HebrewCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::IslamicCivilCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("hijri"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::IslamicCivilCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::IndianNationalCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("indian-national"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::IndianNationalCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::JalaliCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("jalali"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::JalaliCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::JapaneseCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("japanese"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::JapaneseCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::JulianCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("julian"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::JulianCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::MinguoCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("minguo"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::MinguoCalendar);
|
||||
delete calendar;
|
||||
calendar = KCalendarSystem::create(KLocale::ThaiCalendar);
|
||||
QCOMPARE(calendar->calendarType(), QString("thai"));
|
||||
QCOMPARE(calendar->calendarSystem(), KLocale::ThaiCalendar);
|
||||
delete calendar;
|
||||
|
||||
QStringList lst = KCalendarSystem::calendarSystems();
|
||||
QCOMPARE(lst.count(), 12);
|
||||
QVERIFY(lst.contains("coptic"));
|
||||
QVERIFY(lst.contains("ethiopian"));
|
||||
QCOMPARE(lst.count(), 3);
|
||||
QVERIFY(lst.contains("gregorian"));
|
||||
QVERIFY(lst.contains("gregorian-proleptic"));
|
||||
QVERIFY(lst.contains("hebrew"));
|
||||
QVERIFY(lst.contains("hijri"));
|
||||
QVERIFY(lst.contains("indian-national"));
|
||||
QVERIFY(lst.contains("jalali"));
|
||||
QVERIFY(lst.contains("japanese"));
|
||||
QVERIFY(lst.contains("julian"));
|
||||
QVERIFY(lst.contains("minguo"));
|
||||
QVERIFY(lst.contains("thai"));
|
||||
|
||||
QList<KLocale::CalendarSystem> list = KCalendarSystem::calendarSystemsList();
|
||||
QCOMPARE(list.count(), 12);
|
||||
QCOMPARE(list.count(), 3);
|
||||
QVERIFY(list.contains(KLocale::QDateCalendar));
|
||||
QVERIFY(list.contains(KLocale::CopticCalendar));
|
||||
QVERIFY(list.contains(KLocale::EthiopianCalendar));
|
||||
QVERIFY(list.contains(KLocale::GregorianCalendar));
|
||||
QVERIFY(list.contains(KLocale::HebrewCalendar));
|
||||
QVERIFY(list.contains(KLocale::IslamicCivilCalendar));
|
||||
QVERIFY(list.contains(KLocale::IndianNationalCalendar));
|
||||
QVERIFY(list.contains(KLocale::JalaliCalendar));
|
||||
QVERIFY(list.contains(KLocale::JapaneseCalendar));
|
||||
QVERIFY(list.contains(KLocale::JulianCalendar));
|
||||
QVERIFY(list.contains(KLocale::MinguoCalendar));
|
||||
QVERIFY(list.contains(KLocale::ThaiCalendar));
|
||||
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("coptic"), QString("Coptic"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("ethiopian"), QString("Ethiopian"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("gregorian"), QString("Gregorian"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("gregorian-proleptic"), QString("Gregorian (Proleptic)"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("hebrew"), QString("Hebrew"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("hijri"), QString("Islamic / Hijri (Civil)"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("indian-national"), QString("Indian National"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("jalali"), QString("Jalali"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("japanese"), QString("Japanese"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("julian"), QString("Julian"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("minguo"), QString("Taiwanese"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel("thai"), QString("Thai"));
|
||||
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::QDateCalendar), QString("Gregorian"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::CopticCalendar), QString("Coptic"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::EthiopianCalendar), QString("Ethiopian"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::GregorianCalendar), QString("Gregorian (Proleptic)"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::HebrewCalendar), QString("Hebrew"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::IslamicCivilCalendar), QString("Islamic / Hijri (Civil)"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::IndianNationalCalendar), QString("Indian National"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::JalaliCalendar), QString("Jalali"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::JapaneseCalendar), QString("Japanese"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::JulianCalendar), QString("Julian"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::MinguoCalendar), QString("Taiwanese"));
|
||||
QCOMPARE(KCalendarSystem::calendarLabel(KLocale::ThaiCalendar), QString("Thai"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -616,98 +616,18 @@ void KLocaleTest::testCalendarSystemType()
|
|||
{
|
||||
KLocale locale(*KGlobal::locale());
|
||||
|
||||
locale.setCalendar("coptic");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::CopticCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("coptic") );
|
||||
|
||||
locale.setCalendar("ethiopian");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::EthiopianCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("ethiopian") );
|
||||
|
||||
locale.setCalendar("gregorian-proleptic");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::GregorianCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("gregorian-proleptic") );
|
||||
|
||||
locale.setCalendar("hebrew");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::HebrewCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("hebrew") );
|
||||
|
||||
locale.setCalendar("hijri");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::IslamicCivilCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("hijri") );
|
||||
|
||||
locale.setCalendar("indian-national");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::IndianNationalCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("indian-national") );
|
||||
|
||||
locale.setCalendar("jalali");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::JalaliCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("jalali") );
|
||||
|
||||
locale.setCalendar("japanese");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::JapaneseCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("japanese") );
|
||||
|
||||
locale.setCalendar("julian");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::JulianCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("julian") );
|
||||
|
||||
locale.setCalendar("minguo");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::MinguoCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("minguo") );
|
||||
|
||||
locale.setCalendar("thai");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::ThaiCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("thai") );
|
||||
|
||||
locale.setCalendar("gregorian");
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::QDateCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("gregorian") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::CopticCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::CopticCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("coptic") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::EthiopianCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::EthiopianCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("ethiopian") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::GregorianCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::GregorianCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("gregorian-proleptic") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::HebrewCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::HebrewCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("hebrew") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::IslamicCivilCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::IslamicCivilCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("hijri") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::IndianNationalCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::IndianNationalCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("indian-national") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::JalaliCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::JalaliCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("jalali") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::JapaneseCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::JapaneseCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("japanese") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::JulianCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::JulianCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("julian") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::MinguoCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::MinguoCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("minguo") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::ThaiCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::ThaiCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("thai") );
|
||||
|
||||
locale.setCalendarSystem(KLocale::QDateCalendar);
|
||||
QCOMPARE( locale.calendarSystem(), KLocale::QDateCalendar);
|
||||
QCOMPARE( locale.calendarType(), QString("gregorian") );
|
||||
|
|
Loading…
Add table
Reference in a new issue