• Skip to content
  • Skip to link menu
KDE 4.7 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDECore

kcalendarsystemminguo.cpp
Go to the documentation of this file.
00001 /*
00002     Copyright 2010 John Layt <john@layt.net>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kcalendarsystemminguo_p.h"
00021 #include "kcalendarsystemgregorianprivate_p.h"
00022 
00023 #include "kdebug.h"
00024 #include "klocale.h"
00025 
00026 #include <QtCore/QDate>
00027 
00028 //Reuse the Gregorian private implementation
00029 class KCalendarSystemMinguoPrivate : public KCalendarSystemGregorianPrivate
00030 {
00031 public:
00032     explicit KCalendarSystemMinguoPrivate(KCalendarSystemMinguo *q);
00033     virtual ~KCalendarSystemMinguoPrivate();
00034 
00035     virtual KLocale::CalendarSystem calendarSystem() const;
00036     virtual void loadDefaultEraList();
00037     virtual bool isLeapYear(int year) const;
00038     virtual int earliestValidYear() const;
00039 };
00040 
00041 //Override only a few of the Gregorian private methods
00042 
00043 KCalendarSystemMinguoPrivate::KCalendarSystemMinguoPrivate(KCalendarSystemMinguo *q)
00044                             : KCalendarSystemGregorianPrivate(q)
00045 {
00046 }
00047 
00048 KCalendarSystemMinguoPrivate::~KCalendarSystemMinguoPrivate()
00049 {
00050 }
00051 
00052 KLocale::CalendarSystem KCalendarSystemMinguoPrivate::calendarSystem() const
00053 {
00054     return KLocale::MinguoCalendar;
00055 }
00056 
00057 void KCalendarSystemMinguoPrivate::loadDefaultEraList()
00058 {
00059     QString name, shortName, format;
00060 
00061     name = i18nc("Calendar Era: Taiwan Republic of China Era, years > 0, LongFormat", "Republic of China Era");
00062     shortName = i18nc("Calendar Era: Taiwan Republic of China Era, years > 0, ShortFormat", "ROC");
00063     format = i18nc("(kdedt-format) Taiwan, ROC, full era year format used for %EY, e.g. ROC 99", "%EC %Ey");
00064     addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
00065 }
00066 
00067 bool KCalendarSystemMinguoPrivate::isLeapYear(int year) const
00068 {
00069     return KCalendarSystemGregorianPrivate::isLeapYear(year + 1911);
00070 }
00071 
00072 int KCalendarSystemMinguoPrivate::earliestValidYear() const
00073 {
00074     return 1;
00075 }
00076 
00077 
00078 KCalendarSystemMinguo::KCalendarSystemMinguo(const KLocale *locale)
00079                      : KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), KSharedConfig::Ptr(), locale)
00080 {
00081     d_ptr->loadConfig(calendarType());
00082 }
00083 
00084 KCalendarSystemMinguo::KCalendarSystemMinguo(const KSharedConfig::Ptr config, const KLocale *locale)
00085                      : KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), config, locale)
00086 {
00087     d_ptr->loadConfig(calendarType());
00088 }
00089 
00090 KCalendarSystemMinguo::KCalendarSystemMinguo(KCalendarSystemMinguoPrivate &dd,
00091                                              const KSharedConfig::Ptr config, const KLocale *locale)
00092                      : KCalendarSystemGregorian(dd, config, locale)
00093 {
00094     d_ptr->loadConfig(calendarType());
00095 }
00096 
00097 KCalendarSystemMinguo::~KCalendarSystemMinguo()
00098 {
00099 }
00100 
00101 QString KCalendarSystemMinguo::calendarType() const
00102 {
00103     return QLatin1String("minguo");
00104 }
00105 
00106 QDate KCalendarSystemMinguo::epoch() const
00107 {
00108     // 0001-01-01 = 1912-01-01 AD Gregorian
00109     return QDate::fromJulianDay(2419403);
00110 }
00111 
00112 QDate KCalendarSystemMinguo::earliestValidDate() const
00113 {
00114     return epoch();
00115 }
00116 
00117 QDate KCalendarSystemMinguo::latestValidDate() const
00118 {
00119     // Set to last day of year 9999 until confirm date formats & widgets support > 9999
00120     // 9999-12-31 = 11910-12-31 AD Gregorian
00121     return QDate::fromJulianDay(6071462);
00122 }
00123 
00124 bool KCalendarSystemMinguo::isValid(int year, int month, int day) const
00125 {
00126     return KCalendarSystemGregorian::isValid(year, month, day);
00127 }
00128 
00129 bool KCalendarSystemMinguo::isValid(const QDate &date) const
00130 {
00131     return KCalendarSystemGregorian::isValid(date);
00132 }
00133 
00134 bool KCalendarSystemMinguo::isLeapYear(int year) const
00135 {
00136     return KCalendarSystemGregorian::isLeapYear(year);
00137 }
00138 
00139 bool KCalendarSystemMinguo::isLeapYear(const QDate &date) const
00140 {
00141     return KCalendarSystemGregorian::isLeapYear(date);
00142 }
00143 
00144 QString KCalendarSystemMinguo::monthName(int month, int year, MonthNameFormat format) const
00145 {
00146     return KCalendarSystemGregorian::monthName(month, year, format);
00147 }
00148 
00149 QString KCalendarSystemMinguo::monthName(const QDate &date, MonthNameFormat format) const
00150 {
00151     return KCalendarSystemGregorian::monthName(date, format);
00152 }
00153 
00154 QString KCalendarSystemMinguo::weekDayName(int weekDay, WeekDayNameFormat format) const
00155 {
00156     return KCalendarSystemGregorian::weekDayName(weekDay, format);
00157 }
00158 
00159 QString KCalendarSystemMinguo::weekDayName(const QDate &date, WeekDayNameFormat format) const
00160 {
00161     return KCalendarSystemGregorian::weekDayName(date, format);
00162 }
00163 
00164 int KCalendarSystemMinguo::weekDayOfPray() const
00165 {
00166     return 7; // TODO JPL ???
00167 }
00168 
00169 bool KCalendarSystemMinguo::isLunar() const
00170 {
00171     return KCalendarSystemGregorian::isLunar();
00172 }
00173 
00174 bool KCalendarSystemMinguo::isLunisolar() const
00175 {
00176     return KCalendarSystemGregorian::isLunisolar();
00177 }
00178 
00179 bool KCalendarSystemMinguo::isSolar() const
00180 {
00181     return KCalendarSystemGregorian::isSolar();
00182 }
00183 
00184 bool KCalendarSystemMinguo::isProleptic() const
00185 {
00186     return false;
00187 }
00188 
00189 bool KCalendarSystemMinguo::julianDayToDate(int jd, int &year, int &month, int &day) const
00190 {
00191     bool result = KCalendarSystemGregorian::julianDayToDate(jd, year, month, day);
00192     year = year - 1911;
00193     return result;
00194 }
00195 
00196 bool KCalendarSystemMinguo::dateToJulianDay(int year, int month, int day, int &jd) const
00197 {
00198     return KCalendarSystemGregorian::dateToJulianDay(year + 1911, month, day, jd);
00199 }
00200 

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal