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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • date
kcalendarsystemjalali.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2003 Arash Bijanzadeh and FarsiKDE Project <www.farsikde.org>
3  Contact: Arash Bijanzadeh <a.bijanzadeh@linuxiran.org>
4  Copyright 2007, 2008, 2009, 2010 John Layt <john@layt.net>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 /*
23  This is an implementation of the artithmetic Persian calendar using the
24  Birashk algorithm with adjustments to always be correct in the period 1244
25  and 1530 (1865 to 2152 Gregorian).
26 
27  In future this will be replaced with the correct astronomical calendar.
28 */
29 
30 #include "kcalendarsystemjalali_p.h"
31 #include "kcalendarsystemprivate_p.h"
32 
33 #include <QtCore/QDate>
34 
35 class KCalendarSystemJalaliPrivate : public KCalendarSystemPrivate
36 {
37 public:
38  explicit KCalendarSystemJalaliPrivate(KCalendarSystemJalali *q);
39 
40  virtual ~KCalendarSystemJalaliPrivate();
41 
42  // Virtual methods each calendar system must re-implement
43  virtual KLocale::CalendarSystem calendarSystem() const;
44  virtual void loadDefaultEraList();
45  virtual int monthsInYear(int year) const;
46  virtual int daysInMonth(int year, int month) const;
47  virtual int daysInYear(int year) const;
48  virtual int daysInWeek() const;
49  virtual bool isLeapYear(int year) const;
50  virtual bool hasLeapMonths() const;
51  virtual bool hasYearZero() const;
52  virtual int maxDaysInWeek() const;
53  virtual int maxMonthsInYear() const;
54  virtual int earliestValidYear() const;
55  virtual int latestValidYear() const;
56  virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const;
57  virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
58 };
59 
60 // Shared d pointer base class definitions
61 
62 KCalendarSystemJalaliPrivate::KCalendarSystemJalaliPrivate(KCalendarSystemJalali *q)
63  : KCalendarSystemPrivate(q)
64 {
65 }
66 
67 KCalendarSystemJalaliPrivate::~KCalendarSystemJalaliPrivate()
68 {
69 }
70 
71 KLocale::CalendarSystem KCalendarSystemJalaliPrivate::calendarSystem() const
72 {
73  return KLocale::JalaliCalendar;
74 }
75 
76 void KCalendarSystemJalaliPrivate::loadDefaultEraList()
77 {
78  QString name, shortName, format;
79  // Islamic Era (Hijri), Anno Persico.
80  name = i18nc("Calendar Era: Jalali Islamic Era, years > 0, LongFormat", "Anno Persico");
81  shortName = i18nc("Calendar Era: Jalali Islamic Era, years > 0, ShortFormat", "AP");
82  format = i18nc("(kdedt-format) Jalali, AP, full era year format used for %EY, e.g. 2000 AP", "%Ey %EC");
83  addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
84 }
85 
86 int KCalendarSystemJalaliPrivate::monthsInYear(int year) const
87 {
88  Q_UNUSED(year)
89  return 12;
90 }
91 
92 int KCalendarSystemJalaliPrivate::daysInMonth(int year, int month) const
93 {
94  if (month == 12) {
95  if (isLeapYear(year)) {
96  return 30;
97  } else {
98  return 29;
99  }
100  }
101 
102  if (month <= 6) {
103  return 31;
104  }
105 
106  return 30;
107 }
108 
109 int KCalendarSystemJalaliPrivate::daysInYear(int year) const
110 {
111  if (isLeapYear(year)) {
112  return 366;
113  } else {
114  return 365;
115  }
116 }
117 
118 int KCalendarSystemJalaliPrivate::daysInWeek() const
119 {
120  return 7;
121 }
122 
123 bool KCalendarSystemJalaliPrivate::isLeapYear(int year) const
124 {
125  // From formilab Public Domain code http://www.fourmilab.ch/documents/calendar/
126  // Use Birashk algorithm as it matches the to/from jd code below
127 
128  // Birashk algorithm is incorrect in two years in period AP 1244 to 1531,
129  // 1403/1404 and 1436/1437, and so catch them here first
130  if (year == 1403 || year == 1436) {
131  return true;
132  } else if (year == 1404 || year == 1437) {
133  return false;
134  }
135 
136  if (year >= 0) {
137  year = year - 474;
138  } else {
139  year = year - 473;
140  }
141 
142  if ((((((year % 2820) + 474) + 38) * 682) % 2816) < 682) {
143  return true;
144  } else {
145  return false;
146  }
147 }
148 
149 bool KCalendarSystemJalaliPrivate::hasLeapMonths() const
150 {
151  return false;
152 }
153 
154 bool KCalendarSystemJalaliPrivate::hasYearZero() const
155 {
156  return false;
157 }
158 
159 int KCalendarSystemJalaliPrivate::maxDaysInWeek() const
160 {
161  return 7;
162 }
163 
164 int KCalendarSystemJalaliPrivate::maxMonthsInYear() const
165 {
166  return 12;
167 }
168 
169 int KCalendarSystemJalaliPrivate::earliestValidYear() const
170 {
171  return 1244;
172 }
173 
174 int KCalendarSystemJalaliPrivate::latestValidYear() const
175 {
176  return 1530;
177 }
178 
179 QString KCalendarSystemJalaliPrivate::monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive) const
180 {
181  Q_UNUSED(year);
182 
183  if (format == KLocale::NarrowName) {
184  switch (month) {
185  case 1:
186  return ki18nc("Jalali month 1 - KLocale::NarrowName", "F").toString(locale());
187  case 2:
188  return ki18nc("Jalali month 2 - KLocale::NarrowName", "O").toString(locale());
189  case 3:
190  return ki18nc("Jalali month 3 - KLocale::NarrowName", "K").toString(locale());
191  case 4:
192  return ki18nc("Jalali month 4 - KLocale::NarrowName", "T").toString(locale());
193  case 5:
194  return ki18nc("Jalali month 5 - KLocale::NarrowName", "M").toString(locale());
195  case 6:
196  return ki18nc("Jalali month 6 - KLocale::NarrowName", "S").toString(locale());
197  case 7:
198  return ki18nc("Jalali month 7 - KLocale::NarrowName", "M").toString(locale());
199  case 8:
200  return ki18nc("Jalali month 8 - KLocale::NarrowName", "A").toString(locale());
201  case 9:
202  return ki18nc("Jalali month 9 - KLocale::NarrowName", "A").toString(locale());
203  case 10:
204  return ki18nc("Jalali month 10 - KLocale::NarrowName", "D").toString(locale());
205  case 11:
206  return ki18nc("Jalali month 11 - KLocale::NarrowName", "B").toString(locale());
207  case 12:
208  return ki18nc("Jalali month 12 - KLocale::NarrowName", "E").toString(locale());
209  default:
210  return QString();
211  }
212  }
213 
214  if (format == KLocale::ShortName && possessive) {
215  switch (month) {
216  case 1:
217  return ki18nc("Jalali month 1 - KLocale::ShortName Possessive", "of Far").toString(locale());
218  case 2:
219  return ki18nc("Jalali month 2 - KLocale::ShortName Possessive", "of Ord").toString(locale());
220  case 3:
221  return ki18nc("Jalali month 3 - KLocale::ShortName Possessive", "of Kho").toString(locale());
222  case 4:
223  return ki18nc("Jalali month 4 - KLocale::ShortName Possessive", "of Tir").toString(locale());
224  case 5:
225  return ki18nc("Jalali month 5 - KLocale::ShortName Possessive", "of Mor").toString(locale());
226  case 6:
227  return ki18nc("Jalali month 6 - KLocale::ShortName Possessive", "of Sha").toString(locale());
228  case 7:
229  return ki18nc("Jalali month 7 - KLocale::ShortName Possessive", "of Meh").toString(locale());
230  case 8:
231  return ki18nc("Jalali month 8 - KLocale::ShortName Possessive", "of Aba").toString(locale());
232  case 9:
233  return ki18nc("Jalali month 9 - KLocale::ShortName Possessive", "of Aza").toString(locale());
234  case 10:
235  return ki18nc("Jalali month 10 - KLocale::ShortName Possessive", "of Dei").toString(locale());
236  case 11:
237  return ki18nc("Jalali month 11 - KLocale::ShortName Possessive", "of Bah").toString(locale());
238  case 12:
239  return ki18nc("Jalali month 12 - KLocale::ShortName Possessive", "of Esf").toString(locale());
240  default:
241  return QString();
242  }
243  }
244 
245  if (format == KLocale::ShortName && !possessive) {
246  switch (month) {
247  case 1:
248  return ki18nc("Jalali month 1 - KLocale::ShortName", "Far").toString(locale());
249  case 2:
250  return ki18nc("Jalali month 2 - KLocale::ShortName", "Ord").toString(locale());
251  case 3:
252  return ki18nc("Jalali month 3 - KLocale::ShortName", "Kho").toString(locale());
253  case 4:
254  return ki18nc("Jalali month 4 - KLocale::ShortName", "Tir").toString(locale());
255  case 5:
256  return ki18nc("Jalali month 5 - KLocale::ShortName", "Mor").toString(locale());
257  case 6:
258  return ki18nc("Jalali month 6 - KLocale::ShortName", "Sha").toString(locale());
259  case 7:
260  return ki18nc("Jalali month 7 - KLocale::ShortName", "Meh").toString(locale());
261  case 8:
262  return ki18nc("Jalali month 8 - KLocale::ShortName", "Aba").toString(locale());
263  case 9:
264  return ki18nc("Jalali month 9 - KLocale::ShortName", "Aza").toString(locale());
265  case 10:
266  return ki18nc("Jalali month 10 - KLocale::ShortName", "Dei").toString(locale());
267  case 11:
268  return ki18nc("Jalali month 11 - KLocale::ShortName", "Bah").toString(locale());
269  case 12:
270  return ki18nc("Jalali month 12 - KLocale::ShortName", "Esf").toString(locale());
271  default:
272  return QString();
273  }
274  }
275 
276  if (format == KLocale::LongName && possessive) {
277  switch (month) {
278  case 1:
279  return ki18nc("Jalali month 1 - KLocale::LongName Possessive", "of Farvardin").toString(locale());
280  case 2:
281  return ki18nc("Jalali month 2 - KLocale::LongName Possessive", "of Ordibehesht").toString(locale());
282  case 3:
283  return ki18nc("Jalali month 3 - KLocale::LongName Possessive", "of Khordad").toString(locale());
284  case 4:
285  return ki18nc("Jalali month 4 - KLocale::LongName Possessive", "of Tir").toString(locale());
286  case 5:
287  return ki18nc("Jalali month 5 - KLocale::LongName Possessive", "of Mordad").toString(locale());
288  case 6:
289  return ki18nc("Jalali month 6 - KLocale::LongName Possessive", "of Shahrivar").toString(locale());
290  case 7:
291  return ki18nc("Jalali month 7 - KLocale::LongName Possessive", "of Mehr").toString(locale());
292  case 8:
293  return ki18nc("Jalali month 8 - KLocale::LongName Possessive", "of Aban").toString(locale());
294  case 9:
295  return ki18nc("Jalali month 9 - KLocale::LongName Possessive", "of Azar").toString(locale());
296  case 10:
297  return ki18nc("Jalali month 10 - KLocale::LongName Possessive", "of Dei").toString(locale());
298  case 11:
299  return ki18nc("Jalali month 11 - KLocale::LongName Possessive", "of Bahman").toString(locale());
300  case 12:
301  return ki18nc("Jalali month 12 - KLocale::LongName Possessive", "of Esfand").toString(locale());
302  default:
303  return QString();
304  }
305  }
306 
307  // Default to LongName
308  switch (month) {
309  case 1:
310  return ki18nc("Jalali month 1 - KLocale::LongName", "Farvardin").toString(locale());
311  case 2:
312  return ki18nc("Jalali month 2 - KLocale::LongName", "Ordibehesht").toString(locale());
313  case 3:
314  return ki18nc("Jalali month 3 - KLocale::LongName", "Khordad").toString(locale());
315  case 4:
316  return ki18nc("Jalali month 4 - KLocale::LongName", "Tir").toString(locale());
317  case 5:
318  return ki18nc("Jalali month 5 - KLocale::LongName", "Mordad").toString(locale());
319  case 6:
320  return ki18nc("Jalali month 6 - KLocale::LongName", "Shahrivar").toString(locale());
321  case 7:
322  return ki18nc("Jalali month 7 - KLocale::LongName", "Mehr").toString(locale());
323  case 8:
324  return ki18nc("Jalali month 8 - KLocale::LongName", "Aban").toString(locale());
325  case 9:
326  return ki18nc("Jalali month 9 - KLocale::LongName", "Azar").toString(locale());
327  case 10:
328  return ki18nc("Jalali month 10 - KLocale::LongName", "Dei").toString(locale());
329  case 11:
330  return ki18nc("Jalali month 11 - KLocale::LongName", "Bahman").toString(locale());
331  case 12:
332  return ki18nc("Jalali month 12 - KLocale::LongName", "Esfand").toString(locale());
333  default:
334  return QString();
335  }
336 }
337 
338 QString KCalendarSystemJalaliPrivate::weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
339 {
340  if (format == KLocale::NarrowName) {
341  switch (weekDay) {
342  case 1:
343  return ki18nc("Jalali weekday 1 - KLocale::NarrowName ", "2").toString(locale());
344  case 2:
345  return ki18nc("Jalali weekday 2 - KLocale::NarrowName ", "3").toString(locale());
346  case 3:
347  return ki18nc("Jalali weekday 3 - KLocale::NarrowName ", "4").toString(locale());
348  case 4:
349  return ki18nc("Jalali weekday 4 - KLocale::NarrowName ", "5").toString(locale());
350  case 5:
351  return ki18nc("Jalali weekday 5 - KLocale::NarrowName ", "J").toString(locale());
352  case 6:
353  return ki18nc("Jalali weekday 6 - KLocale::NarrowName ", "S").toString(locale());
354  case 7:
355  return ki18nc("Jalali weekday 7 - KLocale::NarrowName ", "1").toString(locale());
356  default:
357  return QString();
358  }
359  }
360 
361  if (format == KLocale::ShortName || format == KLocale:: ShortNumber) {
362  switch (weekDay) {
363  case 1:
364  return ki18nc("Jalali weekday 1 - KLocale::ShortName", "2sh").toString(locale());
365  case 2:
366  return ki18nc("Jalali weekday 2 - KLocale::ShortName", "3sh").toString(locale());
367  case 3:
368  return ki18nc("Jalali weekday 3 - KLocale::ShortName", "4sh").toString(locale());
369  case 4:
370  return ki18nc("Jalali weekday 4 - KLocale::ShortName", "5sh").toString(locale());
371  case 5:
372  return ki18nc("Jalali weekday 5 - KLocale::ShortName", "Jom").toString(locale());
373  case 6:
374  return ki18nc("Jalali weekday 6 - KLocale::ShortName", "Shn").toString(locale());
375  case 7:
376  return ki18nc("Jalali weekday 7 - KLocale::ShortName", "1sh").toString(locale());
377  default: return QString();
378  }
379  }
380 
381  switch (weekDay) {
382  case 1:
383  return ki18nc("Jalali weekday 1 - KLocale::LongName", "Do shanbe").toString(locale());
384  case 2:
385  return ki18nc("Jalali weekday 2 - KLocale::LongName", "Se shanbe").toString(locale());
386  case 3:
387  return ki18nc("Jalali weekday 3 - KLocale::LongName", "Chahar shanbe").toString(locale());
388  case 4:
389  return ki18nc("Jalali weekday 4 - KLocale::LongName", "Panj shanbe").toString(locale());
390  case 5:
391  return ki18nc("Jalali weekday 5 - KLocale::LongName", "Jumee").toString(locale());
392  case 6:
393  return ki18nc("Jalali weekday 6 - KLocale::LongName", "Shanbe").toString(locale());
394  case 7:
395  return ki18nc("Jalali weekday 7 - KLocale::LongName", "Yek-shanbe").toString(locale());
396  default:
397  return QString();
398  }
399 }
400 
401 
402 KCalendarSystemJalali::KCalendarSystemJalali(const KLocale *locale)
403  : KCalendarSystem(*new KCalendarSystemJalaliPrivate(this), KSharedConfig::Ptr(), locale)
404 {
405  d_ptr->loadConfig(calendarType());
406 }
407 
408 KCalendarSystemJalali::KCalendarSystemJalali(const KSharedConfig::Ptr config, const KLocale *locale)
409  : KCalendarSystem(*new KCalendarSystemJalaliPrivate(this), config, locale)
410 {
411  d_ptr->loadConfig(calendarType());
412 }
413 
414 KCalendarSystemJalali::KCalendarSystemJalali(KCalendarSystemJalaliPrivate &dd,
415  const KSharedConfig::Ptr config, const KLocale *locale)
416  : KCalendarSystem(dd, config, locale)
417 {
418  d_ptr->loadConfig(calendarType());
419 }
420 
421 KCalendarSystemJalali::~KCalendarSystemJalali()
422 {
423 }
424 
425 QString KCalendarSystemJalali::calendarType() const
426 {
427  return QLatin1String("jalali");
428 }
429 
430 QDate KCalendarSystemJalali::epoch() const
431 {
432  // 19 March 622 in the Julian calendar
433  return QDate::fromJulianDay(1948321);
434 }
435 
436 QDate KCalendarSystemJalali::earliestValidDate() const
437 {
438  // Using the Birashk formula which is accurate in period AP 1244 to 1530 (AD 1865 to 2152)
439  // 1244-01-01 Jalali 1865-03-21 Gregorian
440  return QDate::fromJulianDay(2402317);
441 }
442 
443 QDate KCalendarSystemJalali::latestValidDate() const
444 {
445  // Using the Birashk formula which is accurate in period AP 1244 to 1530 (AD 1865 to 2152)
446  // 1530-12-29 Jalali 2152-03-19 Gregorian
447  return QDate::fromJulianDay(2507140);
448 }
449 
450 bool KCalendarSystemJalali::isValid(int year, int month, int day) const
451 {
452  return KCalendarSystem::isValid(year, month, day);
453 }
454 
455 bool KCalendarSystemJalali::isValid(const QDate &date) const
456 {
457  return KCalendarSystem::isValid(date);
458 }
459 
460 bool KCalendarSystemJalali::isLeapYear(int year) const
461 {
462  return KCalendarSystem::isLeapYear(year);
463 }
464 
465 bool KCalendarSystemJalali::isLeapYear(const QDate &date) const
466 {
467  return KCalendarSystem::isLeapYear(date);
468 }
469 
470 QString KCalendarSystemJalali::monthName(int month, int year, MonthNameFormat format) const
471 {
472  return KCalendarSystem::monthName(month, year, format);
473 }
474 
475 QString KCalendarSystemJalali::monthName(const QDate &date, MonthNameFormat format) const
476 {
477  return KCalendarSystem::monthName(date, format);
478 }
479 
480 QString KCalendarSystemJalali::weekDayName(int weekDay, WeekDayNameFormat format) const
481 {
482  return KCalendarSystem::weekDayName(weekDay, format);
483 }
484 
485 QString KCalendarSystemJalali::weekDayName(const QDate &date, WeekDayNameFormat format) const
486 {
487  return KCalendarSystem::weekDayName(date, format);
488 }
489 
490 int KCalendarSystemJalali::weekDayOfPray() const
491 {
492  return 5; // friday
493 }
494 
495 bool KCalendarSystemJalali::isLunar() const
496 {
497  return false;
498 }
499 
500 bool KCalendarSystemJalali::isLunisolar() const
501 {
502  return false;
503 }
504 
505 bool KCalendarSystemJalali::isSolar() const
506 {
507  return true;
508 }
509 
510 bool KCalendarSystemJalali::isProleptic() const
511 {
512  return false;
513 }
514 
515 bool KCalendarSystemJalali::julianDayToDate(int jd, int &year, int &month, int &day) const
516 {
517  // Birashk algorithm is incorrect in two years in period AP 1244 to 1531.
518  // This results in a leap day being added to the end of 1404 instead of 1403
519  // and to the end of 1437 instead of 1436. Check for these dates first and
520  // return accordingly. Relies on later use of dateToJulianDay() to correctly
521  // calculate firstDayOfYear in 1404 and 1437, so no other adjustments needed.
522  if (jd == 2460755) {
523  year = 1403;
524  month = 12;
525  day = 30;
526  return true;
527  }
528  if (jd == 2472808) {
529  year = 1436;
530  month = 12;
531  day = 30;
532  return true;
533  }
534 
535  // From original KDE3 code, source unknown? Unable to contact author or committer to confirm
536  // Matches Fermilab code, EMACS and D&R so check for PD source, likely Birashk's book
537 
538  int jdCycleStart;
539  int daysSinceCycleStart;
540  int cycle;
541  int dayInCycle;
542  int yearInCycle;
543  dateToJulianDay(475, 1, 1, jdCycleStart);
544  daysSinceCycleStart = jd - jdCycleStart;
545  cycle = daysSinceCycleStart / 1029983;
546  dayInCycle = daysSinceCycleStart % 1029983;
547  if (dayInCycle == 1029982) {
548  yearInCycle = 2820;
549  } else {
550  int aux1 = dayInCycle / 366;
551  int aux2 = dayInCycle % 366;
552  yearInCycle = (((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1;
553  }
554  year = yearInCycle + (2820 * cycle) + 474;
555  if (year <= 0) {
556  year = year - 1;
557  }
558 
559  int firstDayOfYear;
560  dateToJulianDay(year, 1, 1, firstDayOfYear);
561  int dayinYear = jd - firstDayOfYear + 1;
562  if (dayinYear <= 186) {
563  month = ((dayinYear - 1) / 31) + 1;
564  day = dayinYear - ((month - 1) * 31);
565  } else {
566  month = ((dayinYear - 7) / 30) + 1;
567  day = dayinYear - ((month - 1) * 30) - 6;
568  }
569 
570  return true;
571 }
572 
573 bool KCalendarSystemJalali::dateToJulianDay(int year, int month, int day, int &jd) const
574 {
575  Q_D(const KCalendarSystemJalali);
576 
577  // Birashk algorithm is incorrect in two years in period AP 1244 to 1531.
578  // This results in a leap day being added to the end of 1404 instead of 1403
579  // and to the end of 1437 instead of 1436. Thus all dates in 1404 and 1437
580  // are off by 1 JD. Check for these dates first and adjust accordingly.
581  if (year == 1403 && month == 12 && day == 30) {
582  jd = 2460755;
583  return true;
584  }
585  if (year == 1436 && month == 12 && day == 30) {
586  jd = 2472808;
587  return true;
588  }
589  if (year == 1404 || year == 1437) {
590  if (month < 12 && day + 1 > d->daysInMonth(year, month)) {
591  day = 1;
592  month = month + 1;
593  } else {
594  day = day + 1;
595  }
596  }
597 
598  // From original KDE3 code, source unknown? Unable to contact author or committer to confirm
599  // Matches Fermilab code, EMACS and D&R so check for PD source, likely Birashk's book
600  int epbase;
601  long epyear;
602  long monthDays;
603 
604  if (year >= 0) {
605  epbase = year - 474;
606  } else {
607  epbase = year - 473;
608  }
609 
610  epyear = 474 + (epbase % 2820);
611 
612  if (month <= 7) {
613  monthDays = (month - 1) * 31;
614  } else {
615  monthDays = ((month - 1) * 30) + 6;
616  }
617 
618  jd = (epoch().toJulianDay() - 1) + // days before epoch
619  (epyear - 1) * 365 + // normal days in previous years
620  (((epyear * 682) - 110) / 2816) + // leap days in previous years
621  (epbase / 2820) * 1029983 +
622  monthDays + // days in previous months this year
623  day; // days in this month
624 
625  return true;
626 }
KCalendarSystemJalali::julianDayToDate
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const
Internal method to convert a Julian Day number into the YMD values for this calendar system...
Definition: kcalendarsystemjalali.cpp:515
KLocale::NarrowName
Narrow text format, may not be unique, e.g.
Definition: klocale.h:913
KSharedPtr< KSharedConfig >
KSharedConfig
KConfig variant using shared memory.
Definition: ksharedconfig.h:40
KLocalizedString::toString
QString toString() const
Finalizes the translation, creates QString with placeholders substituted.
Definition: klocalizedstring.cpp:192
KCalendarSystem::isLeapYear
virtual bool isLeapYear(int year) const =0
Returns whether a given year is a leap year.
Definition: kcalendarsystem.cpp:1720
KCalendarSystemPrivate::earliestValidYear
virtual int earliestValidYear() const
Definition: kcalendarsystem.cpp:371
KCalendarSystem::monthName
virtual QString monthName(int month, int year, MonthNameFormat format=LongName) const =0
Gets specific calendar type month name for a given month number If an invalid month is specified...
Definition: kcalendarsystem.cpp:1842
KCalendarSystemJalali
Jalali calendar type implementation.
Definition: kcalendarsystemjalali_p.h:32
KCalendarSystemPrivate::loadDefaultEraList
virtual void loadDefaultEraList()
Definition: kcalendarsystem.cpp:269
KCalendarSystemPrivate::monthsInYear
virtual int monthsInYear(int year) const
Definition: kcalendarsystem.cpp:277
kcalendarsystemjalali_p.h
KCalendarSystem::day
virtual int day(const QDate &date) const
Returns the day portion of a given date in the current calendar system.
Definition: kcalendarsystem.cpp:1357
KCalendarSystemJalali::weekDayOfPray
virtual int weekDayOfPray() const
Definition: kcalendarsystemjalali.cpp:490
KCalendarSystemJalali::weekDayName
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const
Gets specific calendar type week day name.
Definition: kcalendarsystemjalali.cpp:480
KCalendarSystem::MonthNameFormat
MonthNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:55
KCalendarSystemJalali::KCalendarSystemJalali
KCalendarSystemJalali(const KLocale *locale=0)
Definition: kcalendarsystemjalali.cpp:402
KCalendarSystemPrivate::maxMonthsInYear
virtual int maxMonthsInYear() const
Definition: kcalendarsystem.cpp:362
KLocale::ShortNumber
Number at its natural width, e.g.
Definition: klocale.h:910
KCalendarSystem
KCalendarSystem abstract base class, provides support for local Calendar Systems in KDE...
Definition: kcalendarsystem.h:40
KLocale::DateTimeComponentFormat
DateTimeComponentFormat
Definition: klocale.h:908
i18nc
QString i18nc(const char *ctxt, const char *text)
Returns a localized version of a string and a context.
Definition: klocalizedstring.h:797
KCalendarSystemPrivate::daysInYear
virtual int daysInYear(int year) const
Definition: kcalendarsystem.cpp:304
KGlobal::config
KSharedConfigPtr config()
Returns the general config object.
Definition: kglobal.cpp:139
KCalendarSystemPrivate::daysInWeek
virtual int daysInWeek() const
Definition: kcalendarsystem.cpp:315
KCalendarSystemJalali::earliestValidDate
virtual QDate earliestValidDate() const
Returns the earliest date valid in this calendar system implementation.
Definition: kcalendarsystemjalali.cpp:436
KCalendarSystemJalali::monthName
virtual QString monthName(int month, int year, MonthNameFormat format=LongName) const
Gets specific calendar type month name for a given month number If an invalid month is specified...
Definition: kcalendarsystemjalali.cpp:470
KLocale::CalendarSystem
CalendarSystem
Definition: klocale.h:780
KCalendarSystemJalali::~KCalendarSystemJalali
virtual ~KCalendarSystemJalali()
Definition: kcalendarsystemjalali.cpp:421
KLocale::JalaliCalendar
Jalali Calendar, aka Persian or Iranian, also used in Afghanistan.
Definition: klocale.h:796
KCalendarSystemJalali::isValid
virtual bool isValid(int year, int month, int day) const
Returns whether a given date is valid in this calendar system.
Definition: kcalendarsystemjalali.cpp:450
QDate::toJulianDay
int toJulianDay() const
KLocale::LongName
Long text format, e.g.
Definition: klocale.h:915
KCalendarSystemJalali::isSolar
virtual bool isSolar() const
Returns whether the calendar is solar based.
Definition: kcalendarsystemjalali.cpp:505
QDate
KCalendarSystemJalali::isProleptic
virtual bool isProleptic() const
Returns whether the calendar system is proleptic, i.e.
Definition: kcalendarsystemjalali.cpp:510
KCalendarSystemJalali::calendarType
virtual QString calendarType() const
Definition: kcalendarsystemjalali.cpp:425
QString
KCalendarSystemPrivate::hasLeapMonths
virtual bool hasLeapMonths() const
Definition: kcalendarsystem.cpp:341
kcalendarsystemprivate_p.h
KCalendarSystem::WeekDayNameFormat
WeekDayNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:66
KCalendarSystem::isValid
virtual bool isValid(int year, int month, int day) const =0
Returns whether a given date is valid in this calendar system.
Definition: kcalendarsystem.cpp:1133
KCalendarSystemJalali::isLunisolar
virtual bool isLunisolar() const
Returns whether the calendar is lunisolar based.
Definition: kcalendarsystemjalali.cpp:500
KCalendarSystemPrivate::maxDaysInWeek
virtual int maxDaysInWeek() const
Definition: kcalendarsystem.cpp:355
KCalendarSystemJalali::isLunar
virtual bool isLunar() const
Returns whether the calendar is lunar based.
Definition: kcalendarsystemjalali.cpp:495
KLocale::ShortName
Short text format, e.g.
Definition: klocale.h:914
KGlobal::locale
KLocale * locale()
Returns the global locale object.
Definition: kglobal.cpp:170
KCalendarSystemPrivate::hasYearZero
virtual bool hasYearZero() const
Definition: kcalendarsystem.cpp:348
KCalendarSystemPrivate
Definition: kcalendarsystemprivate_p.h:31
KCalendarSystemPrivate::monthName
virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive=false) const
Definition: kcalendarsystem.cpp:387
KCalendarSystemPrivate::latestValidYear
virtual int latestValidYear() const
Definition: kcalendarsystem.cpp:380
KCalendarSystemPrivate::daysInMonth
virtual int daysInMonth(int year, int month) const
Definition: kcalendarsystem.cpp:285
KCalendarSystemJalali::dateToJulianDay
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const
Internal method to convert YMD values for this calendar system into a Julian Day number.
Definition: kcalendarsystemjalali.cpp:573
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:69
KCalendarSystemPrivate::weekDayName
virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const
Definition: kcalendarsystem.cpp:398
QLatin1String
ki18nc
KLocalizedString ki18nc(const char *ctxt, const char *msg)
Creates localized string from a given message, with added context.
Definition: klocalizedstring.cpp:929
KCalendarSystemJalali::isLeapYear
virtual bool isLeapYear(int year) const
Returns whether a given year is a leap year.
Definition: kcalendarsystemjalali.cpp:460
KCalendarSystemJalali::epoch
virtual QDate epoch() const
Returns a QDate holding the epoch of the calendar system.
Definition: kcalendarsystemjalali.cpp:430
KCalendarSystemPrivate::calendarSystem
virtual KLocale::CalendarSystem calendarSystem() const
Definition: kcalendarsystem.cpp:261
KCalendarSystemPrivate::isLeapYear
virtual bool isLeapYear(int year) const
Definition: kcalendarsystem.cpp:322
QDate::fromJulianDay
QDate fromJulianDay(int jd)
KCalendarSystemJalali::latestValidDate
virtual QDate latestValidDate() const
Returns the latest date valid in this calendar system implementation.
Definition: kcalendarsystemjalali.cpp:443
KCalendarSystem::firstDayOfYear
QDate firstDayOfYear(int year) const
Definition: kcalendarsystem.cpp:1743
KCalendarSystem::weekDayName
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const =0
Gets specific calendar type week day name.
Definition: kcalendarsystem.cpp:1881
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

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 API Reference

Skip menu "kdelibs API Reference"
  • 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

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal