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

KDECore

  • kdecore
  • date
kcalendarsystemprivate_p.h
Go to the documentation of this file.
1 /*
2  Copyright 2010 John Layt <john@layt.net>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KCALENDARSYSTEMPRIVATE_H
21 #define KCALENDARSYSTEMPRIVATE_H
22 
23 class QChar;
24 class QString;
25 class QDate;
26 
27 class KCalendarSystem;
28 class KCalendarEra;
29 class KLocale;
30 
31 class KCalendarSystemPrivate
32 {
33 public:
34  explicit KCalendarSystemPrivate(KCalendarSystem *q);
35 
36  virtual ~KCalendarSystemPrivate();
37 
38  // Virtual methods each calendar system must re-implement
39  virtual KLocale::CalendarSystem calendarSystem() const;
40  virtual void loadDefaultEraList();
41  virtual int monthsInYear(int year) const;
42  virtual int daysInMonth(int year, int month) const;
43  virtual int daysInYear(int year) const;
44  virtual int daysInWeek() const;
45  virtual bool isLeapYear(int year) const;
46  virtual bool hasLeapMonths() const;
47  virtual bool hasYearZero() const;
48  virtual int maxDaysInWeek() const;
49  virtual int maxMonthsInYear() const;
50  virtual int earliestValidYear() const;
51  virtual int latestValidYear() const;
52  virtual QString monthName(int month, int year, KLocale::DateTimeComponentFormat format, bool possessive = false) const;
53  virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const;
54 
55  // Virtual methods to re-implement if special maths needed
56  virtual int week(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem, int *yearNum) const;
57  virtual int isoWeekNumber(const QDate &date, int *yearNum) const;
58  virtual int regularWeekNumber(const QDate &date, int weekStartDay, int firstWeekNumber, int *weekYear) const;
59  virtual int simpleWeekNumber(const QDate &date, int *yearNum) const;
60  virtual int weeksInYear(int year, KLocale::WeekNumberSystem weekNumberSystem) const;
61  virtual int isoWeeksInYear(int year) const;
62  virtual int regularWeeksInYear(int year, int weekStartDay, int firstWeekNumber) const;
63  virtual int simpleWeeksInYear(int year) const;
64 
65  // Virtual methods to re-implement if special maths needed
66  // Currently only Hebrew may need special conversion, rest should be OK
67  virtual int yearsDifference(const QDate &fromDate, const QDate &toDate) const;
68  virtual int monthsDifference(const QDate &fromDate, const QDate &toDate) const;
69  virtual void dateDifference(const QDate &fromDate, const QDate &toDate,
70  int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
71 
72  // Virtual methods to re-implement if special number/string conversion needed
73  // Currently only Hebrew needs special conversion, rest use KLocale DigitSet
74  virtual int integerFromString(const QString &string, int maxLength, int &readLength) const;
75  virtual QString stringFromInteger(int number, int padWidth = 0, QChar padChar = QLatin1Char('0')) const;
76  virtual QString stringFromInteger(int number, int padWidth, QChar padChar, KLocale::DigitSet digitSet) const;
77 
78  // Utility functions
79  bool setAnyDate(QDate &date, int year, int month, int day) const;
80  int addYears(int startYear, int yearsToAdd) const;
81  int differenceYearNumbers(int fromYear, int toYear) const;
82  QDate invalidDate() const;
83  QString simpleDateString(const QString &str) const;
84  int dayOfYear(const QDate &date) const;
85  int dayOfWeek(const QDate &date) const;
86  QDate firstDayOfYear(int year) const;
87  QDate lastDayOfYear(int year) const;
88  QDate firstDayOfMonth(int year, int month) const;
89  QDate lastDayOfMonth(int year, int month) const;
90  const KLocale *locale() const;
91  void loadEraList(const KConfigGroup & cg);
92  void addEra(char direction, int offset, const QDate &startDate, int startYear, const QDate &endDate,
93  const QString &name, const QString &shortName, const QString &format);
94  QList<KCalendarEra> *eraList() const;
95  KCalendarEra era(const QDate &eraDate) const;
96  KCalendarEra era(const QString &eraName, int yearInEra) const;
97  int shortYearWindowStartYear() const;
98  int applyShortYearWindow(int inputYear) const;
99  void loadShortYearWindowStartYear(const KConfigGroup & cg);
100  KSharedConfig::Ptr config();
101  void loadConfig(const QString & calendarType);
102 
103  // Global variables each calendar system must initialise
104  const KCalendarSystem *q;
105  const KLocale *m_locale;
106  KSharedConfig::Ptr m_config;
107  QList<KCalendarEra> *m_eraList;
108  int m_shortYearWindowStartYear;
109 };
110 
111 #endif // KCALENDARSYSTEMPRIVATE_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jun 1 2013 12:05:01 by doxygen 1.8.1.1 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-4.10.4 API Reference

Skip menu "kdelibs-4.10.4 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
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