• 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
kcalendarsystemminguo.cpp
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 #include "kcalendarsystemminguo_p.h"
21 #include "kcalendarsystemgregorianprivate_p.h"
22 
23 #include "kdebug.h"
24 #include "klocale.h"
25 
26 #include <QtCore/QDate>
27 
28 //Reuse the Gregorian private implementation
29 class KCalendarSystemMinguoPrivate : public KCalendarSystemGregorianPrivate
30 {
31 public:
32  explicit KCalendarSystemMinguoPrivate(KCalendarSystemMinguo *q);
33  virtual ~KCalendarSystemMinguoPrivate();
34 
35  virtual KLocale::CalendarSystem calendarSystem() const;
36  virtual void loadDefaultEraList();
37  virtual bool isLeapYear(int year) const;
38  virtual int earliestValidYear() const;
39 };
40 
41 //Override only a few of the Gregorian private methods
42 
43 KCalendarSystemMinguoPrivate::KCalendarSystemMinguoPrivate(KCalendarSystemMinguo *q)
44  : KCalendarSystemGregorianPrivate(q)
45 {
46 }
47 
48 KCalendarSystemMinguoPrivate::~KCalendarSystemMinguoPrivate()
49 {
50 }
51 
52 KLocale::CalendarSystem KCalendarSystemMinguoPrivate::calendarSystem() const
53 {
54  return KLocale::MinguoCalendar;
55 }
56 
57 void KCalendarSystemMinguoPrivate::loadDefaultEraList()
58 {
59  QString name, shortName, format;
60 
61  name = i18nc("Calendar Era: Taiwan Republic of China Era, years > 0, LongFormat", "Republic of China Era");
62  shortName = i18nc("Calendar Era: Taiwan Republic of China Era, years > 0, ShortFormat", "ROC");
63  format = i18nc("(kdedt-format) Taiwan, ROC, full era year format used for %EY, e.g. ROC 99", "%EC %Ey");
64  addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
65 }
66 
67 bool KCalendarSystemMinguoPrivate::isLeapYear(int year) const
68 {
69  return KCalendarSystemGregorianPrivate::isLeapYear(year + 1911);
70 }
71 
72 int KCalendarSystemMinguoPrivate::earliestValidYear() const
73 {
74  return 1;
75 }
76 
77 
78 KCalendarSystemMinguo::KCalendarSystemMinguo(const KLocale *locale)
79  : KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), KSharedConfig::Ptr(), locale)
80 {
81  d_ptr->loadConfig(calendarType());
82 }
83 
84 KCalendarSystemMinguo::KCalendarSystemMinguo(const KSharedConfig::Ptr config, const KLocale *locale)
85  : KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), config, locale)
86 {
87  d_ptr->loadConfig(calendarType());
88 }
89 
90 KCalendarSystemMinguo::KCalendarSystemMinguo(KCalendarSystemMinguoPrivate &dd,
91  const KSharedConfig::Ptr config, const KLocale *locale)
92  : KCalendarSystemGregorian(dd, config, locale)
93 {
94  d_ptr->loadConfig(calendarType());
95 }
96 
97 KCalendarSystemMinguo::~KCalendarSystemMinguo()
98 {
99 }
100 
101 QString KCalendarSystemMinguo::calendarType() const
102 {
103  return QLatin1String("minguo");
104 }
105 
106 QDate KCalendarSystemMinguo::epoch() const
107 {
108  // 0001-01-01 = 1912-01-01 AD Gregorian
109  return QDate::fromJulianDay(2419403);
110 }
111 
112 QDate KCalendarSystemMinguo::earliestValidDate() const
113 {
114  return epoch();
115 }
116 
117 QDate KCalendarSystemMinguo::latestValidDate() const
118 {
119  // Set to last day of year 9999 until confirm date formats & widgets support > 9999
120  // 9999-12-31 = 11910-12-31 AD Gregorian
121  return QDate::fromJulianDay(6071462);
122 }
123 
124 bool KCalendarSystemMinguo::isValid(int year, int month, int day) const
125 {
126  return KCalendarSystemGregorian::isValid(year, month, day);
127 }
128 
129 bool KCalendarSystemMinguo::isValid(const QDate &date) const
130 {
131  return KCalendarSystemGregorian::isValid(date);
132 }
133 
134 bool KCalendarSystemMinguo::isLeapYear(int year) const
135 {
136  return KCalendarSystemGregorian::isLeapYear(year);
137 }
138 
139 bool KCalendarSystemMinguo::isLeapYear(const QDate &date) const
140 {
141  return KCalendarSystemGregorian::isLeapYear(date);
142 }
143 
144 QString KCalendarSystemMinguo::monthName(int month, int year, MonthNameFormat format) const
145 {
146  return KCalendarSystemGregorian::monthName(month, year, format);
147 }
148 
149 QString KCalendarSystemMinguo::monthName(const QDate &date, MonthNameFormat format) const
150 {
151  return KCalendarSystemGregorian::monthName(date, format);
152 }
153 
154 QString KCalendarSystemMinguo::weekDayName(int weekDay, WeekDayNameFormat format) const
155 {
156  return KCalendarSystemGregorian::weekDayName(weekDay, format);
157 }
158 
159 QString KCalendarSystemMinguo::weekDayName(const QDate &date, WeekDayNameFormat format) const
160 {
161  return KCalendarSystemGregorian::weekDayName(date, format);
162 }
163 
164 int KCalendarSystemMinguo::weekDayOfPray() const
165 {
166  return 7; // TODO JPL ???
167 }
168 
169 bool KCalendarSystemMinguo::isLunar() const
170 {
171  return KCalendarSystemGregorian::isLunar();
172 }
173 
174 bool KCalendarSystemMinguo::isLunisolar() const
175 {
176  return KCalendarSystemGregorian::isLunisolar();
177 }
178 
179 bool KCalendarSystemMinguo::isSolar() const
180 {
181  return KCalendarSystemGregorian::isSolar();
182 }
183 
184 bool KCalendarSystemMinguo::isProleptic() const
185 {
186  return false;
187 }
188 
189 bool KCalendarSystemMinguo::julianDayToDate(int jd, int &year, int &month, int &day) const
190 {
191  bool result = KCalendarSystemGregorian::julianDayToDate(jd, year, month, day);
192  year = year - 1911;
193  return result;
194 }
195 
196 bool KCalendarSystemMinguo::dateToJulianDay(int year, int month, int day, int &jd) const
197 {
198  return KCalendarSystemGregorian::dateToJulianDay(year + 1911, month, day, jd);
199 }
200 
KSharedPtr< KSharedConfig >
KCalendarSystemMinguo::isLunisolar
virtual bool isLunisolar() const
Returns whether the calendar is lunisolar based.
Definition: kcalendarsystemminguo.cpp:174
KSharedConfig
KConfig variant using shared memory.
Definition: ksharedconfig.h:40
KCalendarSystemGregorian::weekDayName
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const
Gets specific calendar type week day name.
Definition: kcalendarsystemgregorian.cpp:466
kdebug.h
KCalendarSystemMinguo::isProleptic
virtual bool isProleptic() const
Returns whether the calendar system is proleptic, i.e.
Definition: kcalendarsystemminguo.cpp:184
KCalendarSystemGregorianPrivate::isLeapYear
virtual bool isLeapYear(int year) const
Definition: kcalendarsystemgregorian.cpp:117
KCalendarSystemMinguo::latestValidDate
virtual QDate latestValidDate() const
Returns the latest date valid in this calendar system implementation.
Definition: kcalendarsystemminguo.cpp:117
KCalendarSystemMinguo::KCalendarSystemMinguo
KCalendarSystemMinguo(const KLocale *locale=0)
Definition: kcalendarsystemminguo.cpp:78
KCalendarSystemMinguo
Definition: kcalendarsystemminguo_p.h:38
KCalendarSystemGregorian::isLunar
virtual bool isLunar() const
Returns whether the calendar is lunar based.
Definition: kcalendarsystemgregorian.cpp:486
KCalendarSystem::MonthNameFormat
MonthNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:55
klocale.h
KCalendarSystemMinguo::weekDayOfPray
virtual int weekDayOfPray() const
Definition: kcalendarsystemminguo.cpp:164
KCalendarSystemGregorian::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: kcalendarsystemgregorian.cpp:506
KCalendarSystemGregorian::isLeapYear
virtual bool isLeapYear(int year) const
Returns whether a given year is a leap year.
Definition: kcalendarsystemgregorian.cpp:446
i18nc
QString i18nc(const char *ctxt, const char *text)
Returns a localized version of a string and a context.
Definition: klocalizedstring.h:797
KCalendarSystemGregorianPrivate::loadDefaultEraList
virtual void loadDefaultEraList()
Definition: kcalendarsystemgregorian.cpp:52
KGlobal::config
KSharedConfigPtr config()
Returns the general config object.
Definition: kglobal.cpp:139
KCalendarSystemMinguo::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: kcalendarsystemminguo.cpp:196
KCalendarSystemGregorianPrivate::calendarSystem
virtual KLocale::CalendarSystem calendarSystem() const
Definition: kcalendarsystemgregorian.cpp:45
KCalendarSystemGregorian::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: kcalendarsystemgregorian.cpp:456
KCalendarSystemMinguo::isValid
virtual bool isValid(int year, int month, int day) const
Returns whether a given date is valid in this calendar system.
Definition: kcalendarsystemminguo.cpp:124
KLocale::CalendarSystem
CalendarSystem
Definition: klocale.h:780
KLocale::MinguoCalendar
Minguo Calendar, aka ROC, Republic of China or Taiwanese.
Definition: klocale.h:802
QDate
KCalendarSystemMinguo::isLunar
virtual bool isLunar() const
Returns whether the calendar is lunar based.
Definition: kcalendarsystemminguo.cpp:169
QString
KCalendarSystemGregorianPrivate::earliestValidYear
virtual int earliestValidYear() const
Definition: kcalendarsystemgregorian.cpp:154
KCalendarSystem::WeekDayNameFormat
WeekDayNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:66
KCalendarSystemMinguo::epoch
virtual QDate epoch() const
Returns a QDate holding the epoch of the calendar system.
Definition: kcalendarsystemminguo.cpp:106
KCalendarSystemGregorian
Definition: kcalendarsystemgregorian_p.h:42
kcalendarsystemgregorianprivate_p.h
KCalendarSystemMinguo::calendarType
virtual QString calendarType() const
Definition: kcalendarsystemminguo.cpp:101
KGlobal::locale
KLocale * locale()
Returns the global locale object.
Definition: kglobal.cpp:170
KCalendarSystemGregorianPrivate
Definition: kcalendarsystemgregorianprivate_p.h:27
KCalendarSystemMinguo::isLeapYear
virtual bool isLeapYear(int year) const
Returns whether a given year is a leap year.
Definition: kcalendarsystemminguo.cpp:134
KCalendarSystemMinguo::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: kcalendarsystemminguo.cpp:144
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:69
QLatin1String
KCalendarSystemMinguo::isSolar
virtual bool isSolar() const
Returns whether the calendar is solar based.
Definition: kcalendarsystemminguo.cpp:179
KCalendarSystemGregorian::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: kcalendarsystemgregorian.cpp:534
KCalendarSystemMinguo::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: kcalendarsystemminguo.cpp:189
KCalendarSystemGregorian::isLunisolar
virtual bool isLunisolar() const
Returns whether the calendar is lunisolar based.
Definition: kcalendarsystemgregorian.cpp:491
KCalendarSystemGregorian::isSolar
virtual bool isSolar() const
Returns whether the calendar is solar based.
Definition: kcalendarsystemgregorian.cpp:496
KCalendarSystemMinguo::weekDayName
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const
Gets specific calendar type week day name.
Definition: kcalendarsystemminguo.cpp:154
kcalendarsystemminguo_p.h
QDate::fromJulianDay
QDate fromJulianDay(int jd)
KCalendarSystemMinguo::~KCalendarSystemMinguo
virtual ~KCalendarSystemMinguo()
Definition: kcalendarsystemminguo.cpp:97
KCalendarSystemMinguo::earliestValidDate
virtual QDate earliestValidDate() const
Returns the earliest date valid in this calendar system implementation.
Definition: kcalendarsystemminguo.cpp:112
KCalendarSystemGregorian::isValid
virtual bool isValid(int year, int month, int day) const
Returns whether a given date is valid in this calendar system.
Definition: kcalendarsystemgregorian.cpp:436
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