[PATCH 21/23] kcalendarsystem: Make monthName() a simple virtual function.
Jon Severinsson
jon at severinsson.net
Fri Oct 12 15:13:56 UTC 2012
Also move the implementations to the end of their respective file to make the rest move navigatable.
---
kdecore/date/kcalendarsystem.cpp | 32 +--
kdecore/date/kcalendarsystem.h | 2 +-
kdecore/date/kcalendarsystemcoptic.cpp | 304 ++++++++++----------
kdecore/date/kcalendarsystemcoptic_p.h | 1 -
kdecore/date/kcalendarsystemcopticprivate_p.h | 1 -
kdecore/date/kcalendarsystemethiopian.cpp | 201 +++++++------
kdecore/date/kcalendarsystemethiopian_p.h | 1 -
kdecore/date/kcalendarsystemgregorian.cpp | 328 +++++++++++----------
kdecore/date/kcalendarsystemgregorian_p.h | 1 -
kdecore/date/kcalendarsystemgregorianprivate_p.h | 1 -
kdecore/date/kcalendarsystemhebrew.cpp | 287 ++++++++++---------
kdecore/date/kcalendarsystemhebrew_p.h | 1 -
kdecore/date/kcalendarsystemindiannational.cpp | 273 +++++++++---------
kdecore/date/kcalendarsystemindiannational_p.h | 1 -
kdecore/date/kcalendarsystemislamiccivil.cpp | 329 +++++++++++-----------
kdecore/date/kcalendarsystemislamiccivil_p.h | 1 -
kdecore/date/kcalendarsystemjalali.cpp | 329 +++++++++++-----------
kdecore/date/kcalendarsystemjalali_p.h | 1 -
kdecore/date/kcalendarsystemjapanese.cpp | 10 -
kdecore/date/kcalendarsystemjapanese_p.h | 3 -
kdecore/date/kcalendarsystemjulian.cpp | 283 +++++++++----------
kdecore/date/kcalendarsystemjulian_p.h | 1 -
kdecore/date/kcalendarsystemminguo.cpp | 11 -
kdecore/date/kcalendarsystemminguo_p.h | 3 -
kdecore/date/kcalendarsystemprivate_p.h | 1 -
kdecore/date/kcalendarsystemqdate.cpp | 329 +++++++++++-----------
kdecore/date/kcalendarsystemqdate_p.h | 1 -
27 filer ändrade, 1289 tillägg(+), 1447 borttagningar(-)
diff --git a/kdecore/date/kcalendarsystem.cpp b/kdecore/date/kcalendarsystem.cpp
index 13a656c..b937823 100644
--- a/kdecore/date/kcalendarsystem.cpp
+++ b/kdecore/date/kcalendarsystem.cpp
@@ -1162,39 +1162,11 @@ QDate KCalendarSystem::lastDayOfMonth(const QDate &date) const
return QDate();
}
-QString KCalendarSystem::monthName(int month, int year, KCalendarSystem::MonthNameFormat format) const
-{
- Q_D(const KCalendarSystem);
-
- if (!isValid(year, month, 1)) {
- return QString();
- }
-
- if (format == KCalendarSystem::NarrowName) {
- return d->monthName(month, year, KLocale::NarrowName, false);
- }
-
- if (format == KCalendarSystem::ShortNamePossessive) {
- return d->monthName(month, year, KLocale::ShortName, true);
- }
-
- if (format == KCalendarSystem::ShortName) {
- return d->monthName(month, year, KLocale::ShortName, false);
- }
-
- if (format == KCalendarSystem::LongNamePossessive) {
- return d->monthName(month, year, KLocale::LongName, true);
- }
-
- // KCalendarSystem::LongName or any other
- return d->monthName(month, year, KLocale::LongName, false);
-}
-
QString KCalendarSystem::monthName(const QDate &date, MonthNameFormat format) const
{
if (isValid(date)) {
- int year, month;
- getDate(date, &year, &month, 0);
+ int year, month, day;
+ julianDayToDate(date.toJulianDay(), year, month, day);
return monthName(month, year, format);
}
diff --git a/kdecore/date/kcalendarsystem.h b/kdecore/date/kcalendarsystem.h
index 3bac854..1ab8b8f 100644
--- a/kdecore/date/kcalendarsystem.h
+++ b/kdecore/date/kcalendarsystem.h
@@ -663,7 +663,7 @@ public:
* @param format specifies whether the short month name or long month name should be used
* @return name of the month, empty string if any error
*/
- virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
+ QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
/**
* Gets specific calendar type week day name.
diff --git a/kdecore/date/kcalendarsystemcoptic.cpp b/kdecore/date/kcalendarsystemcoptic.cpp
index d06b5a9..82bcc42 100644
--- a/kdecore/date/kcalendarsystemcoptic.cpp
+++ b/kdecore/date/kcalendarsystemcoptic.cpp
@@ -116,6 +116,148 @@ int KCalendarSystemCopticPrivate::latestValidYear() const
return 9999;
}
+
+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");
+}
+
+KLocale::CalendarSystem KCalendarSystemCoptic::calendarSystem() const
+{
+ return KLocale::CopticCalendar;
+}
+
+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::isLeapYear(int year) const
+{
+ return KCalendarSystem::isLeapYear(year);
+}
+
+bool KCalendarSystemCoptic::isLeapYear(const QDate &date) const
+{
+ return KCalendarSystem::isLeapYear(date);
+}
+
+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(qint64 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, qint64 &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;
+}
+
// 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
@@ -141,11 +283,11 @@ int KCalendarSystemCopticPrivate::latestValidYear() const
// * 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
+QString KCalendarSystemCoptic::monthName(int month, int year, MonthNameFormat format) const
{
Q_UNUSED(year);
- if (format == KLocale::NarrowName) {
+ if (format == NarrowName) {
switch (month) {
case 1:
return ki18nc("Coptic month 1 - KLocale::NarrowName", "T").toString(locale());
@@ -178,7 +320,7 @@ QString KCalendarSystemCopticPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::ShortName && possessive) {
+ if (format == ShortNamePossessive) {
switch (month) {
case 1:
return ki18nc("Coptic month 1 - KLocale::ShortName Possessive", "of Tho").toString(locale());
@@ -211,7 +353,7 @@ QString KCalendarSystemCopticPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::ShortName && !possessive) {
+ if (format == ShortName) {
switch (month) {
case 1:
return ki18nc("Coptic month 1 - KLocale::ShortName", "Tho").toString(locale());
@@ -244,7 +386,7 @@ QString KCalendarSystemCopticPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::LongName && possessive) {
+ if (format == LongNamePossessive) {
switch (month) {
case 1:
return ki18nc("Coptic month 1 - KLocale::LongName Possessive", "of Thoout").toString(locale());
@@ -309,155 +451,3 @@ QString KCalendarSystemCopticPrivate::monthName(int month, int year, KLocale::Da
return QString();
}
}
-
-
-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");
-}
-
-KLocale::CalendarSystem KCalendarSystemCoptic::calendarSystem() const
-{
- return KLocale::CopticCalendar;
-}
-
-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::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);
-}
-
-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(qint64 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, qint64 &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;
-}
diff --git a/kdecore/date/kcalendarsystemcoptic_p.h b/kdecore/date/kcalendarsystemcoptic_p.h
index a660f6c..cb2a1bf 100644
--- a/kdecore/date/kcalendarsystemcoptic_p.h
+++ b/kdecore/date/kcalendarsystemcoptic_p.h
@@ -51,7 +51,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
diff --git a/kdecore/date/kcalendarsystemcopticprivate_p.h b/kdecore/date/kcalendarsystemcopticprivate_p.h
index ded0436..7b6f4b1 100644
--- a/kdecore/date/kcalendarsystemcopticprivate_p.h
+++ b/kdecore/date/kcalendarsystemcopticprivate_p.h
@@ -40,7 +40,6 @@ public:
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;
};
#endif // KCALENDARSYSTEMCOPTICPRIVATE_H
diff --git a/kdecore/date/kcalendarsystemethiopian.cpp b/kdecore/date/kcalendarsystemethiopian.cpp
index b0fb07e..ac51c76 100644
--- a/kdecore/date/kcalendarsystemethiopian.cpp
+++ b/kdecore/date/kcalendarsystemethiopian.cpp
@@ -37,7 +37,6 @@ public:
}
virtual void loadDefaultEraList();
- virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const;
};
void KCalendarSystemEthiopianPrivate::loadDefaultEraList()
@@ -50,12 +49,102 @@ void KCalendarSystemEthiopianPrivate::loadDefaultEraList()
addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
}
+
+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");
+}
+
+KLocale::CalendarSystem KCalendarSystemEthiopian::calendarSystem() const
+{
+ return KLocale::EthiopianCalendar;
+}
+
+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::isLeapYear(int year) const
+{
+ return KCalendarSystemCoptic::isLeapYear(year);
+}
+
+bool KCalendarSystemEthiopian::isLeapYear(const QDate &date) const
+{
+ return KCalendarSystemCoptic::isLeapYear(date);
+}
+
+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(qint64 jd, int &year, int &month, int &day) const
+{
+ return KCalendarSystemCoptic::julianDayToDate(jd, year, month, day);
+}
+
+bool KCalendarSystemEthiopian::dateToJulianDay(int year, int month, int day, qint64 &jd) const
+{
+ return KCalendarSystemCoptic::dateToJulianDay(year, month, day, jd);
+}
+
// 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
+QString KCalendarSystemEthiopian::monthName(int month, int year, MonthNameFormat format) const
{
Q_UNUSED(year);
- if (format == KLocale::NarrowName) {
+ if (format == NarrowName) {
switch (month) {
case 1:
return ki18nc("Ethiopian month 1 - KLocale::NarrowName", "M").toString(locale());
@@ -88,7 +177,7 @@ QString KCalendarSystemEthiopianPrivate::monthName(int month, int year, KLocale:
}
}
- if (format == KLocale::ShortName && possessive) {
+ if (format == ShortNamePossessive) {
switch (month) {
case 1:
return ki18nc("Ethiopian month 1 - KLocale::ShortName Possessive", "of Mes").toString(locale());
@@ -121,7 +210,7 @@ QString KCalendarSystemEthiopianPrivate::monthName(int month, int year, KLocale:
}
}
- if (format == KLocale::ShortName && !possessive) {
+ if (format == ShortName) {
switch (month) {
case 1:
return ki18nc("Ethiopian month 1 - KLocale::ShortName", "Mes").toString(locale());
@@ -154,7 +243,7 @@ QString KCalendarSystemEthiopianPrivate::monthName(int month, int year, KLocale:
}
}
- if (format == KLocale::LongName && possessive) {
+ if (format == LongNamePossessive) {
switch (month) {
case 1:
return ki18nc("Ethiopian month 1 - KLocale::LongName Possessive", "of Meskerem").toString(locale());
@@ -219,103 +308,3 @@ QString KCalendarSystemEthiopianPrivate::monthName(int month, int year, KLocale:
return QString();
}
}
-
-
-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");
-}
-
-KLocale::CalendarSystem KCalendarSystemEthiopian::calendarSystem() const
-{
- return KLocale::EthiopianCalendar;
-}
-
-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::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);
-}
-
-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(qint64 jd, int &year, int &month, int &day) const
-{
- return KCalendarSystemCoptic::julianDayToDate(jd, year, month, day);
-}
-
-bool KCalendarSystemEthiopian::dateToJulianDay(int year, int month, int day, qint64 &jd) const
-{
- return KCalendarSystemCoptic::dateToJulianDay(year, month, day, jd);
-}
diff --git a/kdecore/date/kcalendarsystemethiopian_p.h b/kdecore/date/kcalendarsystemethiopian_p.h
index e5d769f..558e090 100644
--- a/kdecore/date/kcalendarsystemethiopian_p.h
+++ b/kdecore/date/kcalendarsystemethiopian_p.h
@@ -52,7 +52,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
diff --git a/kdecore/date/kcalendarsystemgregorian.cpp b/kdecore/date/kcalendarsystemgregorian.cpp
index ef60ee9..5c9b070 100644
--- a/kdecore/date/kcalendarsystemgregorian.cpp
+++ b/kdecore/date/kcalendarsystemgregorian.cpp
@@ -146,165 +146,6 @@ int KCalendarSystemGregorianPrivate::latestValidYear() const
return 9999;
}
-QString KCalendarSystemGregorianPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
-{
- Q_UNUSED(year);
-
- if (format == KLocale::NarrowName) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::NarrowName", "J").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::NarrowName", "F").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::NarrowName", "M").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::NarrowName", "A").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::NarrowName", "M").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::NarrowName", "J").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::NarrowName", "J").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::NarrowName", "A").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::NarrowName", "S").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::NarrowName", "O").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::NarrowName", "N").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::NarrowName", "D").toString(locale());
- default:
- return QString();
- }
- }
-
- if (format == KLocale::ShortName && possessive) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::ShortName Possessive", "of Jan").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::ShortName Possessive", "of Feb").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::ShortName Possessive", "of Mar").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::ShortName Possessive", "of Apr").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::ShortName Possessive", "of May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::ShortName Possessive", "of Jun").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::ShortName Possessive", "of Jul").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::ShortName Possessive", "of Aug").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::ShortName Possessive", "of Sep").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::ShortName Possessive", "of Oct").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::ShortName Possessive", "of Nov").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::ShortName Possessive", "of Dec").toString(locale());
- default:
- return QString();
- }
- }
-
- if (format == KLocale::ShortName && !possessive) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::ShortName", "Jan").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::ShortName", "Feb").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::ShortName", "Mar").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::ShortName", "Apr").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::ShortName", "May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::ShortName", "Jun").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::ShortName", "Jul").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::ShortName", "Aug").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::ShortName", "Sep").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::ShortName", "Oct").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::ShortName", "Nov").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::ShortName", "Dec").toString(locale());
- default:
- return QString();
- }
- }
-
- if (format == KLocale::LongName && possessive) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::LongName Possessive", "of January").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::LongName Possessive", "of February").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::LongName Possessive", "of March").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::LongName Possessive", "of April").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::LongName Possessive", "of May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::LongName Possessive", "of June").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::LongName Possessive", "of July").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::LongName Possessive", "of August").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::LongName Possessive", "of September").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::LongName Possessive", "of October").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::LongName Possessive", "of November").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::LongName Possessive", "of December").toString(locale());
- default:
- return QString();
- }
- }
-
- // Default to LongName
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::LongName", "January").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::LongName", "February").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::LongName", "March").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::LongName", "April").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::LongName", "May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::LongName", "June").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::LongName", "July").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::LongName", "August").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::LongName", "September").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::LongName", "October").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::LongName", "November").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::LongName", "December").toString(locale());
- default:
- return QString();
- }
-}
-
KCalendarSystemGregorian::KCalendarSystemGregorian(const KSharedConfig::Ptr config,
const KLocale *locale)
@@ -364,16 +205,6 @@ bool KCalendarSystemGregorian::isLeapYear(const QDate &date) const
return KCalendarSystem::isLeapYear(date);
}
-QString KCalendarSystemGregorian::monthName(int month, int year, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(month, year, format);
-}
-
-QString KCalendarSystemGregorian::monthName(const QDate &date, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(date, format);
-}
-
int KCalendarSystemGregorian::yearStringToInteger(const QString &sNum, int &iLength) const
{
return KCalendarSystem::yearStringToInteger(sNum, iLength);
@@ -460,3 +291,162 @@ bool KCalendarSystemGregorian::dateToJulianDay(int year, int month, int day, qin
return true;
}
+
+QString KCalendarSystemGregorian::monthName(int month, int year, MonthNameFormat format) const
+{
+ Q_UNUSED(year);
+
+ if (format == NarrowName) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::NarrowName", "J").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::NarrowName", "F").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::NarrowName", "M").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::NarrowName", "A").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::NarrowName", "M").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::NarrowName", "J").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::NarrowName", "J").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::NarrowName", "A").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::NarrowName", "S").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::NarrowName", "O").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::NarrowName", "N").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::NarrowName", "D").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ if (format == ShortNamePossessive) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::ShortName Possessive", "of Jan").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::ShortName Possessive", "of Feb").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::ShortName Possessive", "of Mar").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::ShortName Possessive", "of Apr").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::ShortName Possessive", "of May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::ShortName Possessive", "of Jun").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::ShortName Possessive", "of Jul").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::ShortName Possessive", "of Aug").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::ShortName Possessive", "of Sep").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::ShortName Possessive", "of Oct").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::ShortName Possessive", "of Nov").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::ShortName Possessive", "of Dec").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ if (format == ShortName) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::ShortName", "Jan").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::ShortName", "Feb").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::ShortName", "Mar").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::ShortName", "Apr").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::ShortName", "May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::ShortName", "Jun").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::ShortName", "Jul").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::ShortName", "Aug").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::ShortName", "Sep").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::ShortName", "Oct").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::ShortName", "Nov").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::ShortName", "Dec").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ if (format == LongNamePossessive) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::LongName Possessive", "of January").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::LongName Possessive", "of February").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::LongName Possessive", "of March").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::LongName Possessive", "of April").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::LongName Possessive", "of May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::LongName Possessive", "of June").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::LongName Possessive", "of July").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::LongName Possessive", "of August").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::LongName Possessive", "of September").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::LongName Possessive", "of October").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::LongName Possessive", "of November").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::LongName Possessive", "of December").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ // Default to LongName
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::LongName", "January").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::LongName", "February").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::LongName", "March").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::LongName", "April").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::LongName", "May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::LongName", "June").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::LongName", "July").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::LongName", "August").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::LongName", "September").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::LongName", "October").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::LongName", "November").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::LongName", "December").toString(locale());
+ default:
+ return QString();
+ }
+}
diff --git a/kdecore/date/kcalendarsystemgregorian_p.h b/kdecore/date/kcalendarsystemgregorian_p.h
index e289f7e..c608a82 100644
--- a/kdecore/date/kcalendarsystemgregorian_p.h
+++ b/kdecore/date/kcalendarsystemgregorian_p.h
@@ -56,7 +56,6 @@ public:
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 int yearStringToInteger(const QString &sNum, int &iLength) const;
diff --git a/kdecore/date/kcalendarsystemgregorianprivate_p.h b/kdecore/date/kcalendarsystemgregorianprivate_p.h
index 80408b7..d871863 100644
--- a/kdecore/date/kcalendarsystemgregorianprivate_p.h
+++ b/kdecore/date/kcalendarsystemgregorianprivate_p.h
@@ -42,7 +42,6 @@ public:
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;
bool m_useCommonEra;
};
diff --git a/kdecore/date/kcalendarsystemhebrew.cpp b/kdecore/date/kcalendarsystemhebrew.cpp
index 8685bcf..3a386b9 100644
--- a/kdecore/date/kcalendarsystemhebrew.cpp
+++ b/kdecore/date/kcalendarsystemhebrew.cpp
@@ -253,7 +253,6 @@ public:
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 int integerFromString(const QString &string, int maxLength, int &readLength) const;
virtual QString stringFromInteger(int number, int padWidth = 0, QChar padChar = QLatin1Char('0')) const;
@@ -610,12 +609,147 @@ int KCalendarSystemHebrewPrivate::monthNumberToMonthIndex(int year, int month) c
return month;
}
-QString KCalendarSystemHebrewPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
+
+KCalendarSystemHebrew::KCalendarSystemHebrew(const KSharedConfig::Ptr config, const KLocale *locale)
+ : KCalendarSystem(*new KCalendarSystemHebrewPrivate(this), config, locale)
+{
+ d_ptr->loadConfig(calendarType());
+}
+
+KCalendarSystemHebrew::KCalendarSystemHebrew(KCalendarSystemHebrewPrivate &dd,
+ const KSharedConfig::Ptr config, const KLocale *locale)
+ : KCalendarSystem(dd, config, locale)
+{
+ d_ptr->loadConfig(calendarType());
+}
+
+KCalendarSystemHebrew::~KCalendarSystemHebrew()
+{
+}
+
+QString KCalendarSystemHebrew::calendarType() const
+{
+ return QLatin1String("hebrew");
+}
+
+KLocale::CalendarSystem KCalendarSystemHebrew::calendarSystem() const
+{
+ return KLocale::HebrewCalendar;
+}
+
+QDate KCalendarSystemHebrew::epoch() const
+{
+ // Hebrew 0001-01-01 (Gregorian -3760-09-07, Julian -3761-10-07)
+ return QDate::fromJulianDay(347998);
+}
+
+QDate KCalendarSystemHebrew::earliestValidDate() const
+{
+ // Current formulas using direct Gregorian <-> Hebrew conversion using Qt
+ // will return invalid results prior to the Gregorian switchover in 1582
+ // Next valid Hebrew year starts 5344-01-01 (Gregorian 1583-09-17)
+ return QDate::fromJulianDay(2299498);
+}
+
+QDate KCalendarSystemHebrew::latestValidDate() const
+{
+ // Testing shows current formulas only work up to 8119-13-29 (Gregorian 4359-10-07)
+ return QDate::fromJulianDay(3313431);
+}
+
+bool KCalendarSystemHebrew::isLeapYear(int year) const
+{
+ return KCalendarSystem::isLeapYear(year);
+}
+
+bool KCalendarSystemHebrew::isLeapYear(const QDate &date) const
{
+ return KCalendarSystem::isLeapYear(date);
+}
+
+int KCalendarSystemHebrew::yearStringToInteger(const QString &string, int &readLength) const
+{
+ int result = KCalendarSystem::yearStringToInteger(string, readLength);
+
+ // Hebrew has no letter for 0, so 5 and 5000 are written the same
+ // Assume if less than 10 then we are in an exact multiple of 1000
+ if (result < 10) {
+ result = result * 1000;
+ }
+
+ // Not good just assuming, make configurable
+ if (result < 1000) {
+ result += 5000; // assume we're in the 6th millenium (y6k bug)
+ }
+
+ return result;
+}
+
+bool KCalendarSystemHebrew::isLunar() const
+{
+ return false;
+}
+
+bool KCalendarSystemHebrew::isLunisolar() const
+{
+ return true;
+}
+
+bool KCalendarSystemHebrew::isSolar() const
+{
+ return false;
+}
+
+bool KCalendarSystemHebrew::isProleptic() const
+{
+ return false;
+}
+
+bool KCalendarSystemHebrew::julianDayToDate(qint64 jd, int &year, int &month, int &day) const
+{
+ class h_date * sd = toHebrew(QDate::fromJulianDay(jd));
+
+ year = sd->hd_year;
+
+ month = sd->hd_mon;
+ if (isLeapYear(sd->hd_year)) {
+ if (month == 13 /*AdarI*/) {
+ month = 6;
+ } else if (month == 14 /*AdarII*/) {
+ month = 7;
+ } else if (month > 6 && month < 13) {
+ ++month;
+ }
+ }
+
+ day = sd->hd_day;
+
+ return true;
+}
+
+bool KCalendarSystemHebrew::dateToJulianDay(int year, int month, int day, qint64 &jd) const
+{
+ class h_date * gd = hebrewToGregorian(year, month, day);
+
+ QDate tempDate(gd->hd_year, gd->hd_mon + 1, gd->hd_day + 1);
+
+ jd = tempDate.toJulianDay();
+
+ return true;
+}
+
+QString KCalendarSystemHebrew::monthName(int month, int year, MonthNameFormat format) const
+{
+ Q_D(const KCalendarSystemHebrew);
+
+ if (!isValid(year, month, 1)) {
+ return QString();
+ }
+
// We must map month number to month index
- int monthIndex = monthNumberToMonthIndex(year, month);
+ int monthIndex = d->monthNumberToMonthIndex(year, month);
- if (format == KLocale::NarrowName) {
+ if (format == NarrowName) {
switch (monthIndex) {
case 1:
return ki18nc("Hebrew month 1 - KLocale::NarrowName", "T").toString(locale());
@@ -650,7 +784,7 @@ QString KCalendarSystemHebrewPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::ShortName && possessive) {
+ if (format == ShortNamePossessive) {
switch (monthIndex) {
case 1:
return ki18nc("Hebrew month 1 - KLocale::ShortName Possessive", "of Tis").toString(locale());
@@ -685,7 +819,7 @@ QString KCalendarSystemHebrewPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::ShortName && !possessive) {
+ if (format == ShortName) {
switch (monthIndex) {
case 1:
return ki18nc("Hebrew month 1 - KLocale::ShortName", "Tis").toString(locale());
@@ -720,7 +854,7 @@ QString KCalendarSystemHebrewPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::LongName && possessive) {
+ if (format == LongNamePossessive) {
switch (monthIndex) {
case 1:
return ki18nc("Hebrew month 1 - KLocale::LongName Possessive", "of Tishrey").toString(locale());
@@ -789,142 +923,3 @@ QString KCalendarSystemHebrewPrivate::monthName(int month, int year, KLocale::Da
return QString();
}
}
-
-
-KCalendarSystemHebrew::KCalendarSystemHebrew(const KSharedConfig::Ptr config, const KLocale *locale)
- : KCalendarSystem(*new KCalendarSystemHebrewPrivate(this), config, locale)
-{
- d_ptr->loadConfig(calendarType());
-}
-
-KCalendarSystemHebrew::KCalendarSystemHebrew(KCalendarSystemHebrewPrivate &dd,
- const KSharedConfig::Ptr config, const KLocale *locale)
- : KCalendarSystem(dd, config, locale)
-{
- d_ptr->loadConfig(calendarType());
-}
-
-KCalendarSystemHebrew::~KCalendarSystemHebrew()
-{
-}
-
-QString KCalendarSystemHebrew::calendarType() const
-{
- return QLatin1String("hebrew");
-}
-
-KLocale::CalendarSystem KCalendarSystemHebrew::calendarSystem() const
-{
- return KLocale::HebrewCalendar;
-}
-
-QDate KCalendarSystemHebrew::epoch() const
-{
- // Hebrew 0001-01-01 (Gregorian -3760-09-07, Julian -3761-10-07)
- return QDate::fromJulianDay(347998);
-}
-
-QDate KCalendarSystemHebrew::earliestValidDate() const
-{
- // Current formulas using direct Gregorian <-> Hebrew conversion using Qt
- // will return invalid results prior to the Gregorian switchover in 1582
- // Next valid Hebrew year starts 5344-01-01 (Gregorian 1583-09-17)
- return QDate::fromJulianDay(2299498);
-}
-
-QDate KCalendarSystemHebrew::latestValidDate() const
-{
- // Testing shows current formulas only work up to 8119-13-29 (Gregorian 4359-10-07)
- return QDate::fromJulianDay(3313431);
-}
-
-bool KCalendarSystemHebrew::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemHebrew::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
-QString KCalendarSystemHebrew::monthName(int month, int year, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(month, year, format);
-}
-
-QString KCalendarSystemHebrew::monthName(const QDate &date, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(date, format);
-}
-
-int KCalendarSystemHebrew::yearStringToInteger(const QString &string, int &readLength) const
-{
- int result = KCalendarSystem::yearStringToInteger(string, readLength);
-
- // Hebrew has no letter for 0, so 5 and 5000 are written the same
- // Assume if less than 10 then we are in an exact multiple of 1000
- if (result < 10) {
- result = result * 1000;
- }
-
- // Not good just assuming, make configurable
- if (result < 1000) {
- result += 5000; // assume we're in the 6th millenium (y6k bug)
- }
-
- return result;
-}
-
-bool KCalendarSystemHebrew::isLunar() const
-{
- return false;
-}
-
-bool KCalendarSystemHebrew::isLunisolar() const
-{
- return true;
-}
-
-bool KCalendarSystemHebrew::isSolar() const
-{
- return false;
-}
-
-bool KCalendarSystemHebrew::isProleptic() const
-{
- return false;
-}
-
-bool KCalendarSystemHebrew::julianDayToDate(qint64 jd, int &year, int &month, int &day) const
-{
- class h_date * sd = toHebrew(QDate::fromJulianDay(jd));
-
- year = sd->hd_year;
-
- month = sd->hd_mon;
- if (isLeapYear(sd->hd_year)) {
- if (month == 13 /*AdarI*/) {
- month = 6;
- } else if (month == 14 /*AdarII*/) {
- month = 7;
- } else if (month > 6 && month < 13) {
- ++month;
- }
- }
-
- day = sd->hd_day;
-
- return true;
-}
-
-bool KCalendarSystemHebrew::dateToJulianDay(int year, int month, int day, qint64 &jd) const
-{
- class h_date * gd = hebrewToGregorian(year, month, day);
-
- QDate tempDate(gd->hd_year, gd->hd_mon + 1, gd->hd_day + 1);
-
- jd = tempDate.toJulianDay();
-
- return true;
-}
diff --git a/kdecore/date/kcalendarsystemhebrew_p.h b/kdecore/date/kcalendarsystemhebrew_p.h
index 19e640a..ccfbb37 100644
--- a/kdecore/date/kcalendarsystemhebrew_p.h
+++ b/kdecore/date/kcalendarsystemhebrew_p.h
@@ -55,7 +55,6 @@ public:
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 int yearStringToInteger(const QString &sNum, int &iLength) const;
diff --git a/kdecore/date/kcalendarsystemindiannational.cpp b/kdecore/date/kcalendarsystemindiannational.cpp
index 7a4016a..1389cd8 100644
--- a/kdecore/date/kcalendarsystemindiannational.cpp
+++ b/kdecore/date/kcalendarsystemindiannational.cpp
@@ -44,7 +44,6 @@ public:
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;
};
// Shared d pointer base class definitions
@@ -145,11 +144,137 @@ int KCalendarSystemIndianNationalPrivate::latestValidYear() const
return 9999;
}
-QString KCalendarSystemIndianNationalPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
+
+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");
+}
+
+KLocale::CalendarSystem KCalendarSystemIndianNational::calendarSystem() const
+{
+ return KLocale::IndianNationalCalendar;
+}
+
+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::isLeapYear(int year) const
+{
+ return KCalendarSystem::isLeapYear(year);
+}
+
+bool KCalendarSystemIndianNational::isLeapYear(const QDate &date) const
+{
+ return KCalendarSystem::isLeapYear(date);
+}
+
+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(qint64 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, qint64 &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;
+}
+
+QString KCalendarSystemIndianNational::monthName(int month, int year, MonthNameFormat format) const
{
Q_UNUSED(year);
- if (format == KLocale::NarrowName) {
+ if (format == NarrowName) {
switch (month) {
case 1:
return ki18nc("Indian National month 1 - KLocale::NarrowName", "C").toString(locale());
@@ -180,7 +305,7 @@ QString KCalendarSystemIndianNationalPrivate::monthName(int month, int year, KLo
}
}
- if (format == KLocale::ShortName && possessive) {
+ if (format == ShortNamePossessive) {
switch (month) {
case 1:
return ki18nc("Indian National month 1 - KLocale::ShortName Possessive", "of Cha").toString(locale());
@@ -211,7 +336,7 @@ QString KCalendarSystemIndianNationalPrivate::monthName(int month, int year, KLo
}
}
- if (format == KLocale::ShortName && !possessive) {
+ if (format == ShortName) {
switch (month) {
case 1:
return ki18nc("Indian National month 1 - KLocale::ShortName", "Cha").toString(locale());
@@ -242,7 +367,7 @@ QString KCalendarSystemIndianNationalPrivate::monthName(int month, int year, KLo
}
}
- if (format == KLocale::LongName && possessive) {
+ if (format == LongNamePossessive) {
switch (month) {
case 1:
return ki18nc("Indian National month 1 - KLocale::LongName Possessive", "of Chaitra").toString(locale());
@@ -303,139 +428,3 @@ QString KCalendarSystemIndianNationalPrivate::monthName(int month, int year, KLo
return QString();
}
}
-
-
-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");
-}
-
-KLocale::CalendarSystem KCalendarSystemIndianNational::calendarSystem() const
-{
- return KLocale::IndianNationalCalendar;
-}
-
-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::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);
-}
-
-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(qint64 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, qint64 &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;
-}
diff --git a/kdecore/date/kcalendarsystemindiannational_p.h b/kdecore/date/kcalendarsystemindiannational_p.h
index 504e607..88d2d9c 100644
--- a/kdecore/date/kcalendarsystemindiannational_p.h
+++ b/kdecore/date/kcalendarsystemindiannational_p.h
@@ -55,7 +55,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
diff --git a/kdecore/date/kcalendarsystemislamiccivil.cpp b/kdecore/date/kcalendarsystemislamiccivil.cpp
index 26e8c99..1d116b3 100644
--- a/kdecore/date/kcalendarsystemislamiccivil.cpp
+++ b/kdecore/date/kcalendarsystemislamiccivil.cpp
@@ -42,7 +42,6 @@ public:
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;
};
// Shared d pointer base class definitions
@@ -151,165 +150,6 @@ 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();
- }
-}
-
KCalendarSystemIslamicCivil::KCalendarSystemIslamicCivil(const KSharedConfig::Ptr config, const KLocale *locale)
: KCalendarSystem(*new KCalendarSystemIslamicCivilPrivate(this), config, locale)
@@ -366,16 +206,6 @@ 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);
-}
-
bool KCalendarSystemIslamicCivil::isLunar() const
{
return true;
@@ -486,3 +316,162 @@ bool KCalendarSystemIslamicCivil::dateToJulianDay(int year, int month, int day,
jd = ( 3 + ( 11 * year ) ) / 30 + 354 * year + 30 * month - ( month - 1 ) / 2 + day + epoch().toJulianDay() - 385;
*/
}
+
+QString KCalendarSystemIslamicCivil::monthName(int month, int year, MonthNameFormat format) const
+{
+ Q_UNUSED(year);
+
+ if (format == 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 == ShortNamePossessive) {
+ 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 == ShortName) {
+ 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 == LongNamePossessive) {
+ 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();
+ }
+}
diff --git a/kdecore/date/kcalendarsystemislamiccivil_p.h b/kdecore/date/kcalendarsystemislamiccivil_p.h
index 0fff81a..67e5489 100644
--- a/kdecore/date/kcalendarsystemislamiccivil_p.h
+++ b/kdecore/date/kcalendarsystemislamiccivil_p.h
@@ -57,7 +57,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
diff --git a/kdecore/date/kcalendarsystemjalali.cpp b/kdecore/date/kcalendarsystemjalali.cpp
index 9775056..339f497 100644
--- a/kdecore/date/kcalendarsystemjalali.cpp
+++ b/kdecore/date/kcalendarsystemjalali.cpp
@@ -50,7 +50,6 @@ public:
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;
};
// Shared d pointer base class definitions
@@ -157,165 +156,6 @@ 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();
- }
-}
-
KCalendarSystemJalali::KCalendarSystemJalali(const KSharedConfig::Ptr config, const KLocale *locale)
: KCalendarSystem(*new KCalendarSystemJalaliPrivate(this), config, locale)
@@ -374,16 +214,6 @@ 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);
-}
-
bool KCalendarSystemJalali::isLunar() const
{
return false;
@@ -516,3 +346,162 @@ bool KCalendarSystemJalali::dateToJulianDay(int year, int month, int day, qint64
return true;
}
+
+QString KCalendarSystemJalali::monthName(int month, int year, MonthNameFormat format) const
+{
+ Q_UNUSED(year);
+
+ if (format == 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 == ShortNamePossessive) {
+ 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 == ShortName) {
+ 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 == LongNamePossessive) {
+ 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();
+ }
+}
diff --git a/kdecore/date/kcalendarsystemjalali_p.h b/kdecore/date/kcalendarsystemjalali_p.h
index 5c6f6a2..7f5a4ae 100644
--- a/kdecore/date/kcalendarsystemjalali_p.h
+++ b/kdecore/date/kcalendarsystemjalali_p.h
@@ -46,7 +46,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
diff --git a/kdecore/date/kcalendarsystemjapanese.cpp b/kdecore/date/kcalendarsystemjapanese.cpp
index 3a0d8e7..0ea80cf 100644
--- a/kdecore/date/kcalendarsystemjapanese.cpp
+++ b/kdecore/date/kcalendarsystemjapanese.cpp
@@ -150,16 +150,6 @@ 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);
-}
-
int KCalendarSystemJapanese::yearStringToInteger(const QString &sNum, int &iLength) const
{
QString gannen = i18nc("Japanese year 1 of era", "Gannen");
diff --git a/kdecore/date/kcalendarsystemjapanese_p.h b/kdecore/date/kcalendarsystemjapanese_p.h
index 2e2f126..fc368a2 100644
--- a/kdecore/date/kcalendarsystemjapanese_p.h
+++ b/kdecore/date/kcalendarsystemjapanese_p.h
@@ -51,9 +51,6 @@ public:
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 int yearStringToInteger(const QString &sNum, int &iLength) const;
virtual bool isLunar() const;
diff --git a/kdecore/date/kcalendarsystemjulian.cpp b/kdecore/date/kcalendarsystemjulian.cpp
index e9a8d2c..16cd50e 100644
--- a/kdecore/date/kcalendarsystemjulian.cpp
+++ b/kdecore/date/kcalendarsystemjulian.cpp
@@ -45,7 +45,6 @@ public:
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;
bool m_useCommonEra;
};
@@ -159,11 +158,142 @@ int KCalendarSystemJulianPrivate::latestValidYear() const
return 9999;
}
-QString KCalendarSystemJulianPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
+
+KCalendarSystemJulian::KCalendarSystemJulian(const KSharedConfig::Ptr config, const KLocale *locale)
+ : KCalendarSystem(*new KCalendarSystemJulianPrivate(this), config, locale)
+{
+ d_ptr->loadConfig(calendarType());
+}
+
+KCalendarSystemJulian::KCalendarSystemJulian(KCalendarSystemJulianPrivate &dd,
+ const KSharedConfig::Ptr config, const KLocale *locale)
+ : KCalendarSystem(dd, config, locale)
+{
+ d_ptr->loadConfig(calendarType());
+}
+
+KCalendarSystemJulian::~KCalendarSystemJulian()
+{
+}
+
+QString KCalendarSystemJulian::calendarType() const
+{
+ return QLatin1String("julian");
+}
+
+KLocale::CalendarSystem KCalendarSystemJulian::calendarSystem() const
+{
+ return KLocale::JulianCalendar;
+}
+
+QDate KCalendarSystemJulian::epoch() const
+{
+ return QDate::fromJulianDay(1721426);
+}
+
+QDate KCalendarSystemJulian::earliestValidDate() const
+{
+ // 1 Jan 4712 BC, no year zero, cant be 4713BC due to error in QDate that day 0 is not valid
+ // and we really need the first in each year to be valid for the date maths
+ return QDate::fromJulianDay(366);
+}
+
+QDate KCalendarSystemJulian::latestValidDate() const
+{
+ // Set to last day of year 9999 until confirm date formats & widgets support > 9999
+ // 31 Dec 9999 AD, no year zero
+ return QDate::fromJulianDay(5373557);
+}
+
+bool KCalendarSystemJulian::isLeapYear(int year) const
+{
+ return KCalendarSystem::isLeapYear(year);
+}
+
+bool KCalendarSystemJulian::isLeapYear(const QDate &date) const
+{
+ return KCalendarSystem::isLeapYear(date);
+}
+
+bool KCalendarSystemJulian::isLunar() const
+{
+ return false;
+}
+
+bool KCalendarSystemJulian::isLunisolar() const
+{
+ return false;
+}
+
+bool KCalendarSystemJulian::isSolar() const
+{
+ return true;
+}
+
+bool KCalendarSystemJulian::isProleptic() const
+{
+ return true;
+}
+
+bool KCalendarSystemJulian::julianDayToDate(qint64 jd, int &year, int &month, int &day) const
+{
+ // Formula from The Calendar FAQ by Claus Tondering
+ // http://www.tondering.dk/claus/cal/node3.html#SECTION003161000000000000000
+ // NOTE: Coded from scratch from mathematical formulas, not copied from
+ // the Boost licensed source code
+
+ int b = 0;
+ int c = jd + 32082;
+ int d = ((4 * c) + 3) / 1461;
+ int e = c - ((1461 * d) / 4);
+ int m = ((5 * e) + 2) / 153;
+ day = e - (((153 * m) + 2) / 5) + 1;
+ month = m + 3 - (12 * (m / 10));
+ year = (100 * b) + d - 4800 + (m / 10);
+
+ // If year is -ve then is BC. In Julian 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 KCalendarSystemJulian::dateToJulianDay(int year, int month, int day, qint64 &jd) const
+{
+ // Formula from The Calendar FAQ by Claus Tondering
+ // http://www.tondering.dk/claus/cal/node3.html#SECTION003161000000000000000
+ // NOTE: Coded from scratch from mathematical formulas, not copied from
+ // the Boost licensed source code
+
+ // If year is -ve then is BC. In Julian 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;
+ }
+
+ int a = (14 - month) / 12;
+ y = y + 4800 - a;
+ int m = month + (12 * a) - 3;
+
+ jd = day
+ + (((153 * m) + 2) / 5)
+ + (365 * y)
+ + (y / 4)
+ - 32083;
+
+ return true;
+}
+
+QString KCalendarSystemJulian::monthName(int month, int year, MonthNameFormat format) const
{
Q_UNUSED(year);
- if (format == KLocale::NarrowName) {
+ if (format == NarrowName) {
switch (month) {
case 1:
return ki18nc("Julian month 1 - KLocale::NarrowName", "J").toString(locale());
@@ -194,7 +324,7 @@ QString KCalendarSystemJulianPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::ShortName && possessive) {
+ if (format == ShortNamePossessive) {
switch (month) {
case 1:
return ki18nc("Julian month 1 - KLocale::ShortName Possessive", "of Jan").toString(locale());
@@ -225,7 +355,7 @@ QString KCalendarSystemJulianPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::ShortName && !possessive) {
+ if (format == ShortName) {
switch (month) {
case 1:
return ki18nc("Julian month 1 - KLocale::ShortName", "Jan").toString(locale());
@@ -256,7 +386,7 @@ QString KCalendarSystemJulianPrivate::monthName(int month, int year, KLocale::Da
}
}
- if (format == KLocale::LongName && possessive) {
+ if (format == LongNamePossessive) {
switch (month) {
case 1:
return ki18nc("Julian month 1 - KLocale::LongName Possessive", "of January").toString(locale());
@@ -317,144 +447,3 @@ QString KCalendarSystemJulianPrivate::monthName(int month, int year, KLocale::Da
return QString();
}
}
-
-
-KCalendarSystemJulian::KCalendarSystemJulian(const KSharedConfig::Ptr config, const KLocale *locale)
- : KCalendarSystem(*new KCalendarSystemJulianPrivate(this), config, locale)
-{
- d_ptr->loadConfig(calendarType());
-}
-
-KCalendarSystemJulian::KCalendarSystemJulian(KCalendarSystemJulianPrivate &dd,
- const KSharedConfig::Ptr config, const KLocale *locale)
- : KCalendarSystem(dd, config, locale)
-{
- d_ptr->loadConfig(calendarType());
-}
-
-KCalendarSystemJulian::~KCalendarSystemJulian()
-{
-}
-
-QString KCalendarSystemJulian::calendarType() const
-{
- return QLatin1String("julian");
-}
-
-KLocale::CalendarSystem KCalendarSystemJulian::calendarSystem() const
-{
- return KLocale::JulianCalendar;
-}
-
-QDate KCalendarSystemJulian::epoch() const
-{
- return QDate::fromJulianDay(1721426);
-}
-
-QDate KCalendarSystemJulian::earliestValidDate() const
-{
- // 1 Jan 4712 BC, no year zero, cant be 4713BC due to error in QDate that day 0 is not valid
- // and we really need the first in each year to be valid for the date maths
- return QDate::fromJulianDay(366);
-}
-
-QDate KCalendarSystemJulian::latestValidDate() const
-{
- // Set to last day of year 9999 until confirm date formats & widgets support > 9999
- // 31 Dec 9999 AD, no year zero
- return QDate::fromJulianDay(5373557);
-}
-
-bool KCalendarSystemJulian::isLeapYear(int year) const
-{
- return KCalendarSystem::isLeapYear(year);
-}
-
-bool KCalendarSystemJulian::isLeapYear(const QDate &date) const
-{
- return KCalendarSystem::isLeapYear(date);
-}
-
-QString KCalendarSystemJulian::monthName(int month, int year, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(month, year, format);
-}
-
-QString KCalendarSystemJulian::monthName(const QDate &date, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(date, format);
-}
-
-bool KCalendarSystemJulian::isLunar() const
-{
- return false;
-}
-
-bool KCalendarSystemJulian::isLunisolar() const
-{
- return false;
-}
-
-bool KCalendarSystemJulian::isSolar() const
-{
- return true;
-}
-
-bool KCalendarSystemJulian::isProleptic() const
-{
- return true;
-}
-
-bool KCalendarSystemJulian::julianDayToDate(qint64 jd, int &year, int &month, int &day) const
-{
- // Formula from The Calendar FAQ by Claus Tondering
- // http://www.tondering.dk/claus/cal/node3.html#SECTION003161000000000000000
- // NOTE: Coded from scratch from mathematical formulas, not copied from
- // the Boost licensed source code
-
- int b = 0;
- int c = jd + 32082;
- int d = ((4 * c) + 3) / 1461;
- int e = c - ((1461 * d) / 4);
- int m = ((5 * e) + 2) / 153;
- day = e - (((153 * m) + 2) / 5) + 1;
- month = m + 3 - (12 * (m / 10));
- year = (100 * b) + d - 4800 + (m / 10);
-
- // If year is -ve then is BC. In Julian 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 KCalendarSystemJulian::dateToJulianDay(int year, int month, int day, qint64 &jd) const
-{
- // Formula from The Calendar FAQ by Claus Tondering
- // http://www.tondering.dk/claus/cal/node3.html#SECTION003161000000000000000
- // NOTE: Coded from scratch from mathematical formulas, not copied from
- // the Boost licensed source code
-
- // If year is -ve then is BC. In Julian 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;
- }
-
- int a = (14 - month) / 12;
- y = y + 4800 - a;
- int m = month + (12 * a) - 3;
-
- jd = day
- + (((153 * m) + 2) / 5)
- + (365 * y)
- + (y / 4)
- - 32083;
-
- return true;
-}
diff --git a/kdecore/date/kcalendarsystemjulian_p.h b/kdecore/date/kcalendarsystemjulian_p.h
index 6ebe11a..329d7e5 100644
--- a/kdecore/date/kcalendarsystemjulian_p.h
+++ b/kdecore/date/kcalendarsystemjulian_p.h
@@ -55,7 +55,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
diff --git a/kdecore/date/kcalendarsystemminguo.cpp b/kdecore/date/kcalendarsystemminguo.cpp
index 477d090..b01ffda 100644
--- a/kdecore/date/kcalendarsystemminguo.cpp
+++ b/kdecore/date/kcalendarsystemminguo.cpp
@@ -124,16 +124,6 @@ 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);
-}
-
bool KCalendarSystemMinguo::isLunar() const
{
return KCalendarSystemGregorian::isLunar();
@@ -165,4 +155,3 @@ bool KCalendarSystemMinguo::dateToJulianDay(int year, int month, int day, qint64
{
return KCalendarSystemGregorian::dateToJulianDay(year + 1911, month, day, jd);
}
-
diff --git a/kdecore/date/kcalendarsystemminguo_p.h b/kdecore/date/kcalendarsystemminguo_p.h
index d259f12..b0b9fd5 100644
--- a/kdecore/date/kcalendarsystemminguo_p.h
+++ b/kdecore/date/kcalendarsystemminguo_p.h
@@ -51,9 +51,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
virtual bool isSolar() const;
diff --git a/kdecore/date/kcalendarsystemprivate_p.h b/kdecore/date/kcalendarsystemprivate_p.h
index c6c41e0..722e87d 100644
--- a/kdecore/date/kcalendarsystemprivate_p.h
+++ b/kdecore/date/kcalendarsystemprivate_p.h
@@ -46,7 +46,6 @@ public:
virtual int maxMonthsInYear() const = 0;
virtual int earliestValidYear() const = 0;
virtual int latestValidYear() const = 0;
- virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive = false) const = 0;
// Virtual methods to re-implement if special maths needed
// Currently only Hebrew may need special conversion, rest should be OK
diff --git a/kdecore/date/kcalendarsystemqdate.cpp b/kdecore/date/kcalendarsystemqdate.cpp
index 3e5631a..1a905a2 100644
--- a/kdecore/date/kcalendarsystemqdate.cpp
+++ b/kdecore/date/kcalendarsystemqdate.cpp
@@ -50,7 +50,6 @@ public:
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;
bool m_useCommonEra;
};
@@ -145,165 +144,6 @@ int KCalendarSystemQDatePrivate::latestValidYear() const
return 9999;
}
-QString KCalendarSystemQDatePrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
-{
- Q_UNUSED(year);
-
- if (format == KLocale::NarrowName) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::NarrowName", "J").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::NarrowName", "F").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::NarrowName", "M").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::NarrowName", "A").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::NarrowName", "M").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::NarrowName", "J").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::NarrowName", "J").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::NarrowName", "A").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::NarrowName", "S").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::NarrowName", "O").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::NarrowName", "N").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::NarrowName", "D").toString(locale());
- default:
- return QString();
- }
- }
-
- if (format == KLocale::ShortName && possessive) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::ShortName Possessive", "of Jan").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::ShortName Possessive", "of Feb").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::ShortName Possessive", "of Mar").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::ShortName Possessive", "of Apr").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::ShortName Possessive", "of May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::ShortName Possessive", "of Jun").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::ShortName Possessive", "of Jul").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::ShortName Possessive", "of Aug").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::ShortName Possessive", "of Sep").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::ShortName Possessive", "of Oct").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::ShortName Possessive", "of Nov").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::ShortName Possessive", "of Dec").toString(locale());
- default:
- return QString();
- }
- }
-
- if (format == KLocale::ShortName && !possessive) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::ShortName", "Jan").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::ShortName", "Feb").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::ShortName", "Mar").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::ShortName", "Apr").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::ShortName", "May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::ShortName", "Jun").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::ShortName", "Jul").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::ShortName", "Aug").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::ShortName", "Sep").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::ShortName", "Oct").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::ShortName", "Nov").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::ShortName", "Dec").toString(locale());
- default:
- return QString();
- }
- }
-
- if (format == KLocale::LongName && possessive) {
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::LongName Possessive", "of January").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::LongName Possessive", "of February").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::LongName Possessive", "of March").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::LongName Possessive", "of April").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::LongName Possessive", "of May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::LongName Possessive", "of June").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::LongName Possessive", "of July").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::LongName Possessive", "of August").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::LongName Possessive", "of September").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::LongName Possessive", "of October").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::LongName Possessive", "of November").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::LongName Possessive", "of December").toString(locale());
- default:
- return QString();
- }
- }
-
- // Default to LongName
- switch (month) {
- case 1:
- return ki18nc("Gregorian month 1 - KLocale::LongName", "January").toString(locale());
- case 2:
- return ki18nc("Gregorian month 2 - KLocale::LongName", "February").toString(locale());
- case 3:
- return ki18nc("Gregorian month 3 - KLocale::LongName", "March").toString(locale());
- case 4:
- return ki18nc("Gregorian month 4 - KLocale::LongName", "April").toString(locale());
- case 5:
- return ki18nc("Gregorian month 5 - KLocale::LongName", "May").toString(locale());
- case 6:
- return ki18nc("Gregorian month 6 - KLocale::LongName", "June").toString(locale());
- case 7:
- return ki18nc("Gregorian month 7 - KLocale::LongName", "July").toString(locale());
- case 8:
- return ki18nc("Gregorian month 8 - KLocale::LongName", "August").toString(locale());
- case 9:
- return ki18nc("Gregorian month 9 - KLocale::LongName", "September").toString(locale());
- case 10:
- return ki18nc("Gregorian month 10 - KLocale::LongName", "October").toString(locale());
- case 11:
- return ki18nc("Gregorian month 11 - KLocale::LongName", "November").toString(locale());
- case 12:
- return ki18nc("Gregorian month 12 - KLocale::LongName", "December").toString(locale());
- default:
- return QString();
- }
-}
-
KCalendarSystemQDate::KCalendarSystemQDate(const KSharedConfig::Ptr config, const KLocale *locale)
: KCalendarSystem(*new KCalendarSystemQDatePrivate(this), config, locale)
@@ -392,16 +232,6 @@ bool KCalendarSystemQDate::isLeapYear(const QDate &date) const
return QDate::isLeapYear(date.year());
}
-QString KCalendarSystemQDate::monthName(int month, int year, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(month, year, format);
-}
-
-QString KCalendarSystemQDate::monthName(const QDate &date, MonthNameFormat format) const
-{
- return KCalendarSystem::monthName(date, format);
-}
-
bool KCalendarSystemQDate::isLunar() const
{
return false;
@@ -440,3 +270,162 @@ bool KCalendarSystemQDate::dateToJulianDay(int year, int month, int day, qint64
return date.isValid();
}
+
+QString KCalendarSystemQDate::monthName(int month, int year, MonthNameFormat format) const
+{
+ Q_UNUSED(year);
+
+ if (format == NarrowName) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::NarrowName", "J").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::NarrowName", "F").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::NarrowName", "M").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::NarrowName", "A").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::NarrowName", "M").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::NarrowName", "J").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::NarrowName", "J").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::NarrowName", "A").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::NarrowName", "S").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::NarrowName", "O").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::NarrowName", "N").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::NarrowName", "D").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ if (format == ShortNamePossessive) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::ShortName Possessive", "of Jan").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::ShortName Possessive", "of Feb").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::ShortName Possessive", "of Mar").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::ShortName Possessive", "of Apr").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::ShortName Possessive", "of May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::ShortName Possessive", "of Jun").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::ShortName Possessive", "of Jul").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::ShortName Possessive", "of Aug").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::ShortName Possessive", "of Sep").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::ShortName Possessive", "of Oct").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::ShortName Possessive", "of Nov").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::ShortName Possessive", "of Dec").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ if (format == ShortName) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::ShortName", "Jan").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::ShortName", "Feb").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::ShortName", "Mar").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::ShortName", "Apr").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::ShortName", "May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::ShortName", "Jun").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::ShortName", "Jul").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::ShortName", "Aug").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::ShortName", "Sep").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::ShortName", "Oct").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::ShortName", "Nov").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::ShortName", "Dec").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ if (format == LongNamePossessive) {
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::LongName Possessive", "of January").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::LongName Possessive", "of February").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::LongName Possessive", "of March").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::LongName Possessive", "of April").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::LongName Possessive", "of May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::LongName Possessive", "of June").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::LongName Possessive", "of July").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::LongName Possessive", "of August").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::LongName Possessive", "of September").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::LongName Possessive", "of October").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::LongName Possessive", "of November").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::LongName Possessive", "of December").toString(locale());
+ default:
+ return QString();
+ }
+ }
+
+ // Default to LongName
+ switch (month) {
+ case 1:
+ return ki18nc("Julian month 1 - KLocale::LongName", "January").toString(locale());
+ case 2:
+ return ki18nc("Julian month 2 - KLocale::LongName", "February").toString(locale());
+ case 3:
+ return ki18nc("Julian month 3 - KLocale::LongName", "March").toString(locale());
+ case 4:
+ return ki18nc("Julian month 4 - KLocale::LongName", "April").toString(locale());
+ case 5:
+ return ki18nc("Julian month 5 - KLocale::LongName", "May").toString(locale());
+ case 6:
+ return ki18nc("Julian month 6 - KLocale::LongName", "June").toString(locale());
+ case 7:
+ return ki18nc("Julian month 7 - KLocale::LongName", "July").toString(locale());
+ case 8:
+ return ki18nc("Julian month 8 - KLocale::LongName", "August").toString(locale());
+ case 9:
+ return ki18nc("Julian month 9 - KLocale::LongName", "September").toString(locale());
+ case 10:
+ return ki18nc("Julian month 10 - KLocale::LongName", "October").toString(locale());
+ case 11:
+ return ki18nc("Julian month 11 - KLocale::LongName", "November").toString(locale());
+ case 12:
+ return ki18nc("Julian month 12 - KLocale::LongName", "December").toString(locale());
+ default:
+ return QString();
+ }
+}
diff --git a/kdecore/date/kcalendarsystemqdate_p.h b/kdecore/date/kcalendarsystemqdate_p.h
index 55afe5a..bfe85a6 100644
--- a/kdecore/date/kcalendarsystemqdate_p.h
+++ b/kdecore/date/kcalendarsystemqdate_p.h
@@ -64,7 +64,6 @@ public:
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 bool isLunar() const;
virtual bool isLunisolar() const;
--
1.7.10.4
More information about the Kde-frameworks-devel
mailing list