KDECore
kcalendarsystemindiannational.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright 2009, 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 "kcalendarsystemindiannational_p.h" 00021 #include "kcalendarsystemprivate_p.h" 00022 00023 #include "kdebug.h" 00024 #include "klocale.h" 00025 00026 #include <QtCore/QDate> 00027 #include <QtCore/QCharRef> 00028 00029 class KCalendarSystemIndianNationalPrivate : public KCalendarSystemPrivate 00030 { 00031 public: 00032 explicit KCalendarSystemIndianNationalPrivate( KCalendarSystemIndianNational *q ); 00033 00034 virtual ~KCalendarSystemIndianNationalPrivate(); 00035 00036 // Virtual methods each calendar system must re-implement 00037 virtual KLocale::CalendarSystem calendarSystem() const; 00038 virtual void loadDefaultEraList(); 00039 virtual int monthsInYear( int year ) const; 00040 virtual int daysInMonth( int year, int month ) const; 00041 virtual int daysInYear( int year ) const; 00042 virtual int daysInWeek() const; 00043 virtual bool isLeapYear( int year ) const; 00044 virtual bool hasLeapMonths() const; 00045 virtual bool hasYearZero() const; 00046 virtual int maxDaysInWeek() const; 00047 virtual int maxMonthsInYear() const; 00048 virtual int earliestValidYear() const; 00049 virtual int latestValidYear() const; 00050 }; 00051 00052 // Shared d pointer base class definitions 00053 00054 KCalendarSystemIndianNationalPrivate::KCalendarSystemIndianNationalPrivate( KCalendarSystemIndianNational *q ) 00055 :KCalendarSystemPrivate( q ) 00056 { 00057 } 00058 00059 KCalendarSystemIndianNationalPrivate::~KCalendarSystemIndianNationalPrivate() 00060 { 00061 } 00062 00063 KLocale::CalendarSystem KCalendarSystemIndianNationalPrivate::calendarSystem() const 00064 { 00065 return KLocale::IndianNationalCalendar; 00066 } 00067 00068 void KCalendarSystemIndianNationalPrivate::loadDefaultEraList() 00069 { 00070 QString name, shortName, format; 00071 // Saka Era 00072 name = i18nc( "Calendar Era: Indian National Saka Era, years > 0, LongFormat", "Saka Era" ); 00073 shortName = i18nc( "Calendar Era: Indian National Saka Era, years > 0, ShortFormat", "SE" ); 00074 format = i18nc( "(kdedt-format) Indian National, SE, full era year format used for %EY, e.g. 2000 SE", "%Ey %EC" ); 00075 addEra( '+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format ); 00076 } 00077 00078 int KCalendarSystemIndianNationalPrivate::monthsInYear( int year ) const 00079 { 00080 Q_UNUSED( year ) 00081 return 12; 00082 } 00083 00084 int KCalendarSystemIndianNationalPrivate::daysInMonth( int year, int month ) const 00085 { 00086 if ( month == 1 ) { 00087 if ( isLeapYear( year ) ) { 00088 return 31; 00089 } else { 00090 return 30; 00091 } 00092 } 00093 00094 if ( month >= 2 && month <= 6 ) { 00095 return 31; 00096 } 00097 00098 return 30; 00099 } 00100 00101 int KCalendarSystemIndianNationalPrivate::daysInYear( int year ) const 00102 { 00103 if ( isLeapYear( year ) ) { 00104 return 366; 00105 } else { 00106 return 365; 00107 } 00108 } 00109 00110 int KCalendarSystemIndianNationalPrivate::daysInWeek() const 00111 { 00112 return 7; 00113 } 00114 00115 bool KCalendarSystemIndianNationalPrivate::isLeapYear( int year ) const 00116 { 00117 //Uses same rule as Gregorian, and is explicitly synchronized to Gregorian 00118 //so add 78 years to get Gregorian year and apply Gregorian calculation 00119 year = year + 78; 00120 if ( !hasYearZero() && year < 1 ) { 00121 year = year + 1; 00122 } 00123 00124 if ( year % 4 == 0 ) { 00125 if ( year % 100 != 0 ) { 00126 return true; 00127 } else if ( year % 400 == 0 ) { 00128 return true; 00129 } 00130 } 00131 00132 return false; 00133 } 00134 00135 bool KCalendarSystemIndianNationalPrivate::hasLeapMonths() const 00136 { 00137 return false; 00138 } 00139 00140 bool KCalendarSystemIndianNationalPrivate::hasYearZero() const 00141 { 00142 return true; 00143 } 00144 00145 int KCalendarSystemIndianNationalPrivate::maxDaysInWeek() const 00146 { 00147 return 7; 00148 } 00149 00150 int KCalendarSystemIndianNationalPrivate::maxMonthsInYear() const 00151 { 00152 return 12; 00153 } 00154 00155 int KCalendarSystemIndianNationalPrivate::earliestValidYear() const 00156 { 00157 return 0; 00158 } 00159 00160 int KCalendarSystemIndianNationalPrivate::latestValidYear() const 00161 { 00162 return 9999; 00163 } 00164 00165 00166 KCalendarSystemIndianNational::KCalendarSystemIndianNational( const KLocale *locale ) 00167 : KCalendarSystem( *new KCalendarSystemIndianNationalPrivate( this ), KSharedConfig::Ptr(), locale ), 00168 dont_use( 0 ) 00169 { 00170 d_ptr->loadConfig( calendarType() ); 00171 } 00172 00173 KCalendarSystemIndianNational::KCalendarSystemIndianNational( const KSharedConfig::Ptr config, const KLocale *locale ) 00174 : KCalendarSystem( *new KCalendarSystemIndianNationalPrivate( this ), config, locale ), 00175 dont_use( 0 ) 00176 { 00177 d_ptr->loadConfig( calendarType() ); 00178 } 00179 00180 KCalendarSystemIndianNational::KCalendarSystemIndianNational( KCalendarSystemIndianNationalPrivate &dd, 00181 const KSharedConfig::Ptr config, 00182 const KLocale *locale ) 00183 : KCalendarSystem( dd, config, locale ), 00184 dont_use( 0 ) 00185 { 00186 d_ptr->loadConfig( calendarType() ); 00187 } 00188 00189 KCalendarSystemIndianNational::~KCalendarSystemIndianNational() 00190 { 00191 delete dont_use; 00192 } 00193 00194 QString KCalendarSystemIndianNational::calendarType() const 00195 { 00196 return QLatin1String( "indian-national" ); 00197 } 00198 00199 QDate KCalendarSystemIndianNational::epoch() const 00200 { 00201 //0000-01-01, has Year 0. 00202 //0078-03-22 AD Gregorian / 0078-03-24 AD Julian 00203 return QDate::fromJulianDay( 1749994 ); 00204 } 00205 00206 QDate KCalendarSystemIndianNational::earliestValidDate() const 00207 { 00208 //0000-01-01, has Year 0. 00209 //0078-03-22 AD Gregorian / 0078-03-24 AD Julian 00210 //Don't do proleptic yet, need to check 00211 return QDate::fromJulianDay( 1749630 ); 00212 } 00213 00214 QDate KCalendarSystemIndianNational::latestValidDate() const 00215 { 00216 // Set to last day of year 9999 until confirm date formats & widgets support > 9999 00217 //9999-12-30 00218 //10078-03-21 AD Gregorian 00219 return QDate::fromJulianDay( 5402054 ); 00220 } 00221 00222 bool KCalendarSystemIndianNational::isValid( int year, int month, int day ) const 00223 { 00224 return KCalendarSystem::isValid( year, month, day ); 00225 } 00226 00227 bool KCalendarSystemIndianNational::isValid( const QDate &date ) const 00228 { 00229 return KCalendarSystem::isValid( date ); 00230 } 00231 00232 bool KCalendarSystemIndianNational::setDate( QDate &date, int year, int month, int day ) const 00233 { 00234 return KCalendarSystem::setDate( date, year, month, day ); 00235 } 00236 00237 // Deprecated 00238 bool KCalendarSystemIndianNational::setYMD( QDate &date, int y, int m, int d ) const 00239 { 00240 return KCalendarSystem::setDate( date, y, m, d ); 00241 } 00242 00243 int KCalendarSystemIndianNational::year( const QDate &date ) const 00244 { 00245 return KCalendarSystem::year( date ); 00246 } 00247 00248 int KCalendarSystemIndianNational::month( const QDate &date ) const 00249 { 00250 return KCalendarSystem::month( date ); 00251 } 00252 00253 int KCalendarSystemIndianNational::day( const QDate &date ) const 00254 { 00255 return KCalendarSystem::day( date ); 00256 } 00257 00258 QDate KCalendarSystemIndianNational::addYears( const QDate &date, int nyears ) const 00259 { 00260 return KCalendarSystem::addYears( date, nyears ); 00261 } 00262 00263 QDate KCalendarSystemIndianNational::addMonths( const QDate &date, int nmonths ) const 00264 { 00265 return KCalendarSystem::addMonths( date, nmonths ); 00266 } 00267 00268 QDate KCalendarSystemIndianNational::addDays( const QDate &date, int ndays ) const 00269 { 00270 return KCalendarSystem::addDays( date, ndays ); 00271 } 00272 00273 int KCalendarSystemIndianNational::monthsInYear( const QDate &date ) const 00274 { 00275 return KCalendarSystem::monthsInYear( date ); 00276 } 00277 00278 int KCalendarSystemIndianNational::weeksInYear( const QDate &date ) const 00279 { 00280 return KCalendarSystem::weeksInYear( date ); 00281 } 00282 00283 int KCalendarSystemIndianNational::weeksInYear( int year ) const 00284 { 00285 return KCalendarSystem::weeksInYear( year ); 00286 } 00287 00288 int KCalendarSystemIndianNational::daysInYear( const QDate &date ) const 00289 { 00290 return KCalendarSystem::daysInYear( date ); 00291 } 00292 00293 int KCalendarSystemIndianNational::daysInMonth( const QDate &date ) const 00294 { 00295 return KCalendarSystem::daysInMonth( date ); 00296 } 00297 00298 int KCalendarSystemIndianNational::daysInWeek( const QDate &date ) const 00299 { 00300 return KCalendarSystem::daysInWeek( date ); 00301 } 00302 00303 int KCalendarSystemIndianNational::dayOfYear( const QDate &date ) const 00304 { 00305 return KCalendarSystem::dayOfYear( date ); 00306 } 00307 00308 int KCalendarSystemIndianNational::dayOfWeek( const QDate &date ) const 00309 { 00310 return KCalendarSystem::dayOfWeek( date ); 00311 } 00312 00313 int KCalendarSystemIndianNational::weekNumber( const QDate &date, int * yearNum ) const 00314 { 00315 return KCalendarSystem::weekNumber( date, yearNum ); 00316 } 00317 00318 bool KCalendarSystemIndianNational::isLeapYear( int year ) const 00319 { 00320 return KCalendarSystem::isLeapYear( year ); 00321 } 00322 00323 bool KCalendarSystemIndianNational::isLeapYear( const QDate &date ) const 00324 { 00325 return KCalendarSystem::isLeapYear( date ); 00326 } 00327 00328 QString KCalendarSystemIndianNational::monthName( int month, int year, MonthNameFormat format ) const 00329 { 00330 Q_UNUSED( year ); 00331 00332 if ( format == ShortNamePossessive ) { 00333 switch ( month ) { 00334 case 1: 00335 return ki18nc( "Indian National month 1 - ShortNamePossessive", "of Cha" ).toString( locale() ); 00336 case 2: 00337 return ki18nc( "Indian National month 2 - ShortNamePossessive", "of Vai" ).toString( locale() ); 00338 case 3: 00339 return ki18nc( "Indian National month 3 - ShortNamePossessive", "of Jya" ).toString( locale() ); 00340 case 4: 00341 return ki18nc( "Indian National month 4 - ShortNamePossessive", "of Āsh" ).toString( locale() ); 00342 case 5: 00343 return ki18nc( "Indian National month 5 - ShortNamePossessive", "of Shr" ).toString( locale() ); 00344 case 6: 00345 return ki18nc( "Indian National month 6 - ShortNamePossessive", "of Bhā" ).toString( locale() ); 00346 case 7: 00347 return ki18nc( "Indian National month 7 - ShortNamePossessive", "of Āsw" ).toString( locale() ); 00348 case 8: 00349 return ki18nc( "Indian National month 8 - ShortNamePossessive", "of Kār" ).toString( locale() ); 00350 case 9: 00351 return ki18nc( "Indian National month 9 - ShortNamePossessive", "of Agr" ).toString( locale() ); 00352 case 10: 00353 return ki18nc( "Indian National month 10 - ShortNamePossessive", "of Pau" ).toString( locale() ); 00354 case 11: 00355 return ki18nc( "Indian National month 11 - ShortNamePossessive", "of Māg" ).toString( locale() ); 00356 case 12: 00357 return ki18nc( "Indian National month 12 - ShortNamePossessive", "of Phā" ).toString( locale() ); 00358 default: 00359 return QString(); 00360 } 00361 } 00362 00363 if ( format == LongNamePossessive ) { 00364 switch ( month ) { 00365 case 1: 00366 return ki18nc( "Indian National month 1 - LongNamePossessive", "of Chaitra" ).toString( locale() ); 00367 case 2: 00368 return ki18nc( "Indian National month 2 - LongNamePossessive", "of Vaishākh" ).toString( locale() ); 00369 case 3: 00370 return ki18nc( "Indian National month 3 - LongNamePossessive", "of Jyaishtha" ).toString( locale() ); 00371 case 4: 00372 return ki18nc( "Indian National month 4 - LongNamePossessive", "of Āshādha" ).toString( locale() ); 00373 case 5: 00374 return ki18nc( "Indian National month 5 - LongNamePossessive", "of Shrāvana" ).toString( locale() ); 00375 case 6: 00376 return ki18nc( "Indian National month 6 - LongNamePossessive", "of Bhādrapad" ).toString( locale() ); 00377 case 7: 00378 return ki18nc( "Indian National month 7 - LongNamePossessive", "of Āshwin" ).toString( locale() ); 00379 case 8: 00380 return ki18nc( "Indian National month 8 - LongNamePossessive", "of Kārtik" ).toString( locale() ); 00381 case 9: 00382 return ki18nc( "Indian National month 9 - LongNamePossessive", "of Agrahayana" ).toString( locale() ); 00383 case 10: 00384 return ki18nc( "Indian National month 10 - LongNamePossessive", "of Paush" ).toString( locale() ); 00385 case 11: 00386 return ki18nc( "Indian National month 11 - LongNamePossessive", "of Māgh" ).toString( locale() ); 00387 case 12: 00388 return ki18nc( "Indian National month 12 - LongNamePossessive", "of Phālgun" ).toString( locale() ); 00389 default: 00390 return QString(); 00391 } 00392 } 00393 00394 if ( format == ShortName ) { 00395 switch ( month ) { 00396 case 1: 00397 return ki18nc( "Indian National month 1 - ShortName", "Cha" ).toString( locale() ); 00398 case 2: 00399 return ki18nc( "Indian National month 2 - ShortName", "Vai" ).toString( locale() ); 00400 case 3: 00401 return ki18nc( "Indian National month 3 - ShortName", "Jya" ).toString( locale() ); 00402 case 4: 00403 return ki18nc( "Indian National month 4 - ShortName", "Āsh" ).toString( locale() ); 00404 case 5: 00405 return ki18nc( "Indian National month 5 - ShortName", "Shr" ).toString( locale() ); 00406 case 6: 00407 return ki18nc( "Indian National month 6 - ShortName", "Bhā" ).toString( locale() ); 00408 case 7: 00409 return ki18nc( "Indian National month 7 - ShortName", "Āsw" ).toString( locale() ); 00410 case 8: 00411 return ki18nc( "Indian National month 8 - ShortName", "Kār" ).toString( locale() ); 00412 case 9: 00413 return ki18nc( "Indian National month 9 - ShortName", "Agr" ).toString( locale() ); 00414 case 10: 00415 return ki18nc( "Indian National month 10 - ShortName", "Pau" ).toString( locale() ); 00416 case 11: 00417 return ki18nc( "Indian National month 11 - ShortName", "Māg" ).toString( locale() ); 00418 case 12: 00419 return ki18nc( "Indian National month 12 - ShortName", "Phā" ).toString( locale() ); 00420 default: 00421 return QString(); 00422 } 00423 } 00424 00425 // Default to LongName 00426 switch ( month ) { 00427 case 1: 00428 return ki18nc( "Indian National month 1 - LongName", "Chaitra" ).toString( locale() ); 00429 case 2: 00430 return ki18nc( "Indian National month 2 - LongName", "Vaishākh" ).toString( locale() ); 00431 case 3: 00432 return ki18nc( "Indian National month 3 - LongName", "Jyaishtha" ).toString( locale() ); 00433 case 4: 00434 return ki18nc( "Indian National month 4 - LongName", "Āshādha" ).toString( locale() ); 00435 case 5: 00436 return ki18nc( "Indian National month 5 - LongName", "Shrāvana" ).toString( locale() ); 00437 case 6: 00438 return ki18nc( "Indian National month 6 - LongName", "Bhādrapad" ).toString( locale() ); 00439 case 7: 00440 return ki18nc( "Indian National month 7 - LongName", "Āshwin" ).toString( locale() ); 00441 case 8: 00442 return ki18nc( "Indian National month 8 - LongName", "Kārtik" ).toString( locale() ); 00443 case 9: 00444 return ki18nc( "Indian National month 9 - LongName", "Agrahayana" ).toString( locale() ); 00445 case 10: 00446 return ki18nc( "Indian National month 10 - LongName", "Paush" ).toString( locale() ); 00447 case 11: 00448 return ki18nc( "Indian National month 11 - LongName", "Māgh" ).toString( locale() ); 00449 case 12: 00450 return ki18nc( "Indian National month 12 - LongName", "Phālgun" ).toString( locale() ); 00451 default: 00452 return QString(); 00453 } 00454 } 00455 00456 QString KCalendarSystemIndianNational::monthName( const QDate &date, MonthNameFormat format ) const 00457 { 00458 return KCalendarSystem::monthName( date, format ); 00459 } 00460 00461 QString KCalendarSystemIndianNational::weekDayName( int weekDay, WeekDayNameFormat format ) const 00462 { 00463 if ( format == ShortDayName ) { 00464 switch ( weekDay ) { 00465 case 1: return ki18nc( "Indian National weekday 1 - ShortDayName", "Som" ).toString( locale() ); 00466 case 2: return ki18nc( "Indian National weekday 2 - ShortDayName", "Mañ" ).toString( locale() ); 00467 case 3: return ki18nc( "Indian National weekday 3 - ShortDayName", "Bud" ).toString( locale() ); 00468 case 4: return ki18nc( "Indian National weekday 4 - ShortDayName", "Gur" ).toString( locale() ); 00469 case 5: return ki18nc( "Indian National weekday 5 - ShortDayName", "Suk" ).toString( locale() ); 00470 case 6: return ki18nc( "Indian National weekday 6 - ShortDayName", "San" ).toString( locale() ); 00471 case 7: return ki18nc( "Indian National weekday 7 - ShortDayName", "Rav" ).toString( locale() ); 00472 default: return QString(); 00473 } 00474 } 00475 00476 switch ( weekDay ) { 00477 case 1: return ki18nc( "Indian National weekday 1 - LongDayName", "Somavãra" ).toString( locale() ); 00478 case 2: return ki18nc( "Indian National weekday 2 - LongDayName", "Mañgalvã" ).toString( locale() ); 00479 case 3: return ki18nc( "Indian National weekday 3 - LongDayName", "Budhavãra" ).toString( locale() ); 00480 case 4: return ki18nc( "Indian National weekday 4 - LongDayName", "Guruvãra" ).toString( locale() ); 00481 case 5: return ki18nc( "Indian National weekday 5 - LongDayName", "Sukravãra" ).toString( locale() ); 00482 case 6: return ki18nc( "Indian National weekday 6 - LongDayName", "Sanivãra" ).toString( locale() ); 00483 case 7: return ki18nc( "Indian National weekday 7 - LongDayName", "Raviãra" ).toString( locale() ); 00484 default: return QString(); 00485 } 00486 } 00487 00488 QString KCalendarSystemIndianNational::weekDayName( const QDate &date, WeekDayNameFormat format ) const 00489 { 00490 return KCalendarSystem::weekDayName( date, format ); 00491 } 00492 00493 QString KCalendarSystemIndianNational::yearString( const QDate &pDate, StringFormat format ) const 00494 { 00495 return KCalendarSystem::yearString( pDate, format ); 00496 } 00497 00498 QString KCalendarSystemIndianNational::monthString( const QDate &pDate, StringFormat format ) const 00499 { 00500 return KCalendarSystem::monthString( pDate, format ); 00501 } 00502 00503 QString KCalendarSystemIndianNational::dayString( const QDate &pDate, StringFormat format ) const 00504 { 00505 return KCalendarSystem::dayString( pDate, format ); 00506 } 00507 00508 int KCalendarSystemIndianNational::yearStringToInteger( const QString &sNum, int &iLength ) const 00509 { 00510 return KCalendarSystem::yearStringToInteger( sNum, iLength ); 00511 } 00512 00513 int KCalendarSystemIndianNational::monthStringToInteger( const QString &sNum, int &iLength ) const 00514 { 00515 return KCalendarSystem::monthStringToInteger( sNum, iLength ); 00516 } 00517 00518 int KCalendarSystemIndianNational::dayStringToInteger( const QString &sNum, int &iLength ) const 00519 { 00520 return KCalendarSystem::dayStringToInteger( sNum, iLength ); 00521 } 00522 00523 QString KCalendarSystemIndianNational::formatDate( const QDate &date, KLocale::DateFormat format ) const 00524 { 00525 return KCalendarSystem::formatDate( date, format ); 00526 } 00527 00528 QDate KCalendarSystemIndianNational::readDate( const QString &str, bool *ok ) const 00529 { 00530 return KCalendarSystem::readDate( str, ok ); 00531 } 00532 00533 QDate KCalendarSystemIndianNational::readDate( const QString &intstr, const QString &fmt, bool *ok ) const 00534 { 00535 return KCalendarSystem::readDate( intstr, fmt, ok ); 00536 } 00537 00538 QDate KCalendarSystemIndianNational::readDate( const QString &str, KLocale::ReadDateFlags flags, bool *ok ) const 00539 { 00540 return KCalendarSystem::readDate( str, flags, ok ); 00541 } 00542 00543 int KCalendarSystemIndianNational::weekStartDay() const 00544 { 00545 return KCalendarSystem::weekStartDay(); 00546 } 00547 00548 int KCalendarSystemIndianNational::weekDayOfPray() const 00549 { 00550 return 7; // JPL ??? 00551 } 00552 00553 bool KCalendarSystemIndianNational::isLunar() const 00554 { 00555 return false; 00556 } 00557 00558 bool KCalendarSystemIndianNational::isLunisolar() const 00559 { 00560 return true; 00561 } 00562 00563 bool KCalendarSystemIndianNational::isSolar() const 00564 { 00565 return false; 00566 } 00567 00568 bool KCalendarSystemIndianNational::isProleptic() const 00569 { 00570 return false; 00571 } 00572 00573 bool KCalendarSystemIndianNational::julianDayToDate( int jd, int &year, int &month, int &day ) const 00574 { 00575 int L, N, I, J, D, M, Y; 00576 00577 // "Explanatory Supplement to the Astronomical Almanac" 2006 section 12.94 pp 605-606 00578 // Originally from "Report of the Calendar Reform Committee" 1955 00579 L = jd + 68518; 00580 N = ( 4 * L ) / 146097; 00581 L = L - ( 146097 * N + 3 ) / 4; 00582 I = ( 4000 * ( L + 1 ) ) / 1461001; 00583 L = L - ( 1461 * I ) / 4 + 1; 00584 J = ( ( L - 1 ) / 31 ) * ( 1 - L / 185 ) + ( L / 185 ) * ( ( L - 156 ) / 30 + 5 ) - L / 366; 00585 D = L - 31 * J + ( ( J + 2 ) / 8 ) * ( J - 5 ); 00586 L = J / 11; 00587 M = J + 2 - 12 * L; 00588 Y = 100 * ( N - 49 ) + L + I - 78; 00589 00590 day = D; 00591 month = M; 00592 year = Y; 00593 00594 return true; 00595 } 00596 00597 bool KCalendarSystemIndianNational::dateToJulianDay( int year, int month, int day, int &jd ) const 00598 { 00599 int Y = year; 00600 int M = month; 00601 int D = day; 00602 00603 // "Explanatory Supplement to the Astronomical Almanac" 2006 section 12.94 pp 605-606 00604 // Originally from "Report of the Calendar Reform Committee" 1955 00605 jd = 365 * Y 00606 + ( Y + 78 - 1 / M ) / 4 00607 + 31 * M 00608 - ( M + 9 ) / 11 00609 - ( M / 7 ) * ( M - 7 ) 00610 - ( 3 * ( ( Y + 78 - 1 / M ) / 100 + 1 ) ) / 4 00611 + D 00612 + 1749579; 00613 00614 return true; 00615 }
KDE 4.6 API Reference