• Skip to content
  • Skip to link menu
KDE 4.6 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 "kcalendarsystemgregorianprolepticprivate_p.h"
00022 
00023 #include "kdebug.h"
00024 #include "klocale.h"
00025 
00026 #include <QtCore/QDate>
00027 
00028 //Reuse the Gregorian Proleptic private implementation
00029 class KCalendarSystemMinguoPrivate : public KCalendarSystemGregorianProlepticPrivate
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 Proleptic private methods
00042 
00043 KCalendarSystemMinguoPrivate::KCalendarSystemMinguoPrivate( KCalendarSystemMinguo *q )
00044                               : KCalendarSystemGregorianProlepticPrivate( 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 KCalendarSystemGregorianProlepticPrivate::isLeapYear( year + 1911 );
00070 }
00071 
00072 int KCalendarSystemMinguoPrivate::earliestValidYear() const
00073 {
00074     return 1;
00075 }
00076 
00077 
00078 KCalendarSystemMinguo::KCalendarSystemMinguo( const KLocale *locale )
00079                      : KCalendarSystemGregorianProleptic( *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                      : KCalendarSystemGregorianProleptic( *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                      : KCalendarSystemGregorianProleptic( 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 KCalendarSystemGregorianProleptic::isValid( year, month, day );
00127 }
00128 
00129 bool KCalendarSystemMinguo::isValid( const QDate &date ) const
00130 {
00131     return KCalendarSystemGregorianProleptic::isValid( date );
00132 }
00133 
00134 bool KCalendarSystemMinguo::setDate( QDate &date, int year, int month, int day ) const
00135 {
00136     return KCalendarSystemGregorianProleptic::setDate( date, year, month, day );
00137 }
00138 
00139 // Deprecated
00140 bool KCalendarSystemMinguo::setYMD( QDate &date, int y, int m, int d ) const
00141 {
00142     return KCalendarSystemGregorianProleptic::setDate( date, y, m, d );
00143 }
00144 
00145 int KCalendarSystemMinguo::year( const QDate &date ) const
00146 {
00147     return KCalendarSystemGregorianProleptic::year( date );
00148 }
00149 
00150 int KCalendarSystemMinguo::month( const QDate &date ) const
00151 {
00152     return KCalendarSystemGregorianProleptic::month( date );
00153 }
00154 
00155 int KCalendarSystemMinguo::day( const QDate &date ) const
00156 {
00157     return KCalendarSystemGregorianProleptic::day( date );
00158 }
00159 
00160 QDate KCalendarSystemMinguo::addYears( const QDate &date, int nyears ) const
00161 {
00162     return KCalendarSystemGregorianProleptic::addYears( date, nyears );
00163 }
00164 
00165 QDate KCalendarSystemMinguo::addMonths( const QDate &date, int nmonths ) const
00166 {
00167     return KCalendarSystemGregorianProleptic::addMonths( date, nmonths );
00168 }
00169 
00170 QDate KCalendarSystemMinguo::addDays( const QDate &date, int ndays ) const
00171 {
00172     return KCalendarSystemGregorianProleptic::addDays( date, ndays );
00173 }
00174 
00175 int KCalendarSystemMinguo::monthsInYear( const QDate &date ) const
00176 {
00177     return KCalendarSystemGregorianProleptic::monthsInYear( date );
00178 }
00179 
00180 int KCalendarSystemMinguo::weeksInYear( const QDate &date ) const
00181 {
00182     return KCalendarSystemGregorianProleptic::weeksInYear( date );
00183 }
00184 
00185 int KCalendarSystemMinguo::weeksInYear( int year ) const
00186 {
00187     return KCalendarSystemGregorianProleptic::weeksInYear( year );
00188 }
00189 
00190 int KCalendarSystemMinguo::daysInYear( const QDate &date ) const
00191 {
00192     return KCalendarSystemGregorianProleptic::daysInYear( date );
00193 }
00194 
00195 int KCalendarSystemMinguo::daysInMonth( const QDate &date ) const
00196 {
00197     return KCalendarSystemGregorianProleptic::daysInMonth( date );
00198 }
00199 
00200 int KCalendarSystemMinguo::daysInWeek( const QDate &date ) const
00201 {
00202     return KCalendarSystemGregorianProleptic::daysInWeek( date );
00203 }
00204 
00205 int KCalendarSystemMinguo::dayOfYear( const QDate &date ) const
00206 {
00207     return KCalendarSystemGregorianProleptic::dayOfYear( date );
00208 }
00209 
00210 int KCalendarSystemMinguo::dayOfWeek( const QDate &date ) const
00211 {
00212     return KCalendarSystemGregorianProleptic::dayOfWeek( date );
00213 }
00214 
00215 int KCalendarSystemMinguo::weekNumber( const QDate &date, int * yearNum ) const
00216 {
00217     return KCalendarSystemGregorianProleptic::weekNumber( date, yearNum );
00218 }
00219 
00220 bool KCalendarSystemMinguo::isLeapYear( int year ) const
00221 {
00222     return KCalendarSystemGregorianProleptic::isLeapYear( year );
00223 }
00224 
00225 bool KCalendarSystemMinguo::isLeapYear( const QDate &date ) const
00226 {
00227     return KCalendarSystemGregorianProleptic::isLeapYear( date );
00228 }
00229 
00230 QString KCalendarSystemMinguo::monthName( int month, int year, MonthNameFormat format ) const
00231 {
00232     return KCalendarSystemGregorianProleptic::monthName( month, year, format );
00233 }
00234 
00235 QString KCalendarSystemMinguo::monthName( const QDate &date, MonthNameFormat format ) const
00236 {
00237     return KCalendarSystemGregorianProleptic::monthName( date, format );
00238 }
00239 
00240 QString KCalendarSystemMinguo::weekDayName( int weekDay, WeekDayNameFormat format ) const
00241 {
00242     return KCalendarSystemGregorianProleptic::weekDayName( weekDay, format );
00243 }
00244 
00245 QString KCalendarSystemMinguo::weekDayName( const QDate &date, WeekDayNameFormat format ) const
00246 {
00247     return KCalendarSystemGregorianProleptic::weekDayName( date, format );
00248 }
00249 
00250 QString KCalendarSystemMinguo::yearString( const QDate &pDate, StringFormat format ) const
00251 {
00252     return KCalendarSystemGregorianProleptic::yearString( pDate, format );
00253 }
00254 
00255 QString KCalendarSystemMinguo::monthString( const QDate &pDate, StringFormat format ) const
00256 {
00257     return KCalendarSystemGregorianProleptic::monthString( pDate, format );
00258 }
00259 
00260 QString KCalendarSystemMinguo::dayString( const QDate &pDate, StringFormat format ) const
00261 {
00262     return KCalendarSystemGregorianProleptic::dayString( pDate, format );
00263 }
00264 
00265 int KCalendarSystemMinguo::yearStringToInteger( const QString &sNum, int &iLength ) const
00266 {
00267     return KCalendarSystemGregorianProleptic::yearStringToInteger( sNum, iLength );
00268 }
00269 
00270 int KCalendarSystemMinguo::monthStringToInteger( const QString &sNum, int &iLength ) const
00271 {
00272     return KCalendarSystemGregorianProleptic::monthStringToInteger( sNum, iLength );
00273 }
00274 
00275 int KCalendarSystemMinguo::dayStringToInteger( const QString &sNum, int &iLength ) const
00276 {
00277     return KCalendarSystemGregorianProleptic::dayStringToInteger( sNum, iLength );
00278 }
00279 
00280 QString KCalendarSystemMinguo::formatDate( const QDate &date, KLocale::DateFormat format ) const
00281 {
00282     return KCalendarSystemGregorianProleptic::formatDate( date, format );
00283 }
00284 
00285 QDate KCalendarSystemMinguo::readDate( const QString &str, bool *ok ) const
00286 {
00287     return KCalendarSystemGregorianProleptic::readDate( str, ok );
00288 }
00289 
00290 QDate KCalendarSystemMinguo::readDate( const QString &intstr, const QString &fmt, bool *ok ) const
00291 {
00292     return KCalendarSystemGregorianProleptic::readDate( intstr, fmt, ok );
00293 }
00294 
00295 QDate KCalendarSystemMinguo::readDate( const QString &str, KLocale::ReadDateFlags flags, bool *ok ) const
00296 {
00297     return KCalendarSystemGregorianProleptic::readDate( str, flags, ok );
00298 }
00299 
00300 int KCalendarSystemMinguo::weekStartDay() const
00301 {
00302     return KCalendarSystemGregorianProleptic::weekStartDay();
00303 }
00304 
00305 int KCalendarSystemMinguo::weekDayOfPray() const
00306 {
00307     return 7; // TODO JPL ???
00308 }
00309 
00310 bool KCalendarSystemMinguo::isLunar() const
00311 {
00312     return KCalendarSystemGregorianProleptic::isLunar();
00313 }
00314 
00315 bool KCalendarSystemMinguo::isLunisolar() const
00316 {
00317     return KCalendarSystemGregorianProleptic::isLunisolar();
00318 }
00319 
00320 bool KCalendarSystemMinguo::isSolar() const
00321 {
00322     return KCalendarSystemGregorianProleptic::isSolar();
00323 }
00324 
00325 bool KCalendarSystemMinguo::isProleptic() const
00326 {
00327     return false;
00328 }
00329 
00330 bool KCalendarSystemMinguo::julianDayToDate( int jd, int &year, int &month, int &day ) const
00331 {
00332     bool result = KCalendarSystemGregorianProleptic::julianDayToDate( jd, year, month, day );
00333     year = year - 1911;
00334     return result;
00335 }
00336 
00337 bool KCalendarSystemMinguo::dateToJulianDay( int year, int month, int day, int &jd ) const
00338 {
00339     return KCalendarSystemGregorianProleptic::dateToJulianDay( year + 1911, month, day, jd );
00340 }
00341 

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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.3
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