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

KDECore

  • 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
29class KCalendarSystemMinguoPrivate : public KCalendarSystemGregorianPrivate
30{
31public:
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
43KCalendarSystemMinguoPrivate::KCalendarSystemMinguoPrivate(KCalendarSystemMinguo *q)
44 : KCalendarSystemGregorianPrivate(q)
45{
46}
47
48KCalendarSystemMinguoPrivate::~KCalendarSystemMinguoPrivate()
49{
50}
51
52KLocale::CalendarSystem KCalendarSystemMinguoPrivate::calendarSystem() const
53{
54 return KLocale::MinguoCalendar;
55}
56
57void 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
67bool KCalendarSystemMinguoPrivate::isLeapYear(int year) const
68{
69 return KCalendarSystemGregorianPrivate::isLeapYear(year + 1911);
70}
71
72int KCalendarSystemMinguoPrivate::earliestValidYear() const
73{
74 return 1;
75}
76
77
78KCalendarSystemMinguo::KCalendarSystemMinguo(const KLocale *locale)
79 : KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), KSharedConfig::Ptr(), locale)
80{
81 d_ptr->loadConfig(calendarType());
82}
83
84KCalendarSystemMinguo::KCalendarSystemMinguo(const KSharedConfig::Ptr config, const KLocale *locale)
85 : KCalendarSystemGregorian(*new KCalendarSystemMinguoPrivate(this), config, locale)
86{
87 d_ptr->loadConfig(calendarType());
88}
89
90KCalendarSystemMinguo::KCalendarSystemMinguo(KCalendarSystemMinguoPrivate &dd,
91 const KSharedConfig::Ptr config, const KLocale *locale)
92 : KCalendarSystemGregorian(dd, config, locale)
93{
94 d_ptr->loadConfig(calendarType());
95}
96
97KCalendarSystemMinguo::~KCalendarSystemMinguo()
98{
99}
100
101QString KCalendarSystemMinguo::calendarType() const
102{
103 return QLatin1String("minguo");
104}
105
106QDate KCalendarSystemMinguo::epoch() const
107{
108 // 0001-01-01 = 1912-01-01 AD Gregorian
109 return QDate::fromJulianDay(2419403);
110}
111
112QDate KCalendarSystemMinguo::earliestValidDate() const
113{
114 return epoch();
115}
116
117QDate 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
124bool KCalendarSystemMinguo::isValid(int year, int month, int day) const
125{
126 return KCalendarSystemGregorian::isValid(year, month, day);
127}
128
129bool KCalendarSystemMinguo::isValid(const QDate &date) const
130{
131 return KCalendarSystemGregorian::isValid(date);
132}
133
134bool KCalendarSystemMinguo::isLeapYear(int year) const
135{
136 return KCalendarSystemGregorian::isLeapYear(year);
137}
138
139bool KCalendarSystemMinguo::isLeapYear(const QDate &date) const
140{
141 return KCalendarSystemGregorian::isLeapYear(date);
142}
143
144QString KCalendarSystemMinguo::monthName(int month, int year, MonthNameFormat format) const
145{
146 return KCalendarSystemGregorian::monthName(month, year, format);
147}
148
149QString KCalendarSystemMinguo::monthName(const QDate &date, MonthNameFormat format) const
150{
151 return KCalendarSystemGregorian::monthName(date, format);
152}
153
154QString KCalendarSystemMinguo::weekDayName(int weekDay, WeekDayNameFormat format) const
155{
156 return KCalendarSystemGregorian::weekDayName(weekDay, format);
157}
158
159QString KCalendarSystemMinguo::weekDayName(const QDate &date, WeekDayNameFormat format) const
160{
161 return KCalendarSystemGregorian::weekDayName(date, format);
162}
163
164int KCalendarSystemMinguo::weekDayOfPray() const
165{
166 return 7; // TODO JPL ???
167}
168
169bool KCalendarSystemMinguo::isLunar() const
170{
171 return KCalendarSystemGregorian::isLunar();
172}
173
174bool KCalendarSystemMinguo::isLunisolar() const
175{
176 return KCalendarSystemGregorian::isLunisolar();
177}
178
179bool KCalendarSystemMinguo::isSolar() const
180{
181 return KCalendarSystemGregorian::isSolar();
182}
183
184bool KCalendarSystemMinguo::isProleptic() const
185{
186 return false;
187}
188
189bool 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
196bool KCalendarSystemMinguo::dateToJulianDay(int year, int month, int day, int &jd) const
197{
198 return KCalendarSystemGregorian::dateToJulianDay(year + 1911, month, day, jd);
199}
200
KCalendarSystemGregorianPrivate
Definition: kcalendarsystemgregorianprivate_p.h:28
KCalendarSystemGregorianPrivate::calendarSystem
virtual KLocale::CalendarSystem calendarSystem() const
Definition: kcalendarsystemgregorian.cpp:45
KCalendarSystemGregorianPrivate::earliestValidYear
virtual int earliestValidYear() const
Definition: kcalendarsystemgregorian.cpp:154
KCalendarSystemGregorianPrivate::loadDefaultEraList
virtual void loadDefaultEraList()
Definition: kcalendarsystemgregorian.cpp:52
KCalendarSystemGregorianPrivate::isLeapYear
virtual bool isLeapYear(int year) const
Definition: kcalendarsystemgregorian.cpp:117
KCalendarSystemGregorian
Definition: kcalendarsystemgregorian_p.h:43
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
KCalendarSystemGregorian::weekDayName
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const
Gets specific calendar type week day name.
Definition: kcalendarsystemgregorian.cpp:466
KCalendarSystemGregorian::isLeapYear
virtual bool isLeapYear(int year) const
Returns whether a given year is a leap year.
Definition: kcalendarsystemgregorian.cpp:446
KCalendarSystemGregorian::isSolar
virtual bool isSolar() const
Returns whether the calendar is solar based.
Definition: kcalendarsystemgregorian.cpp:496
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
KCalendarSystemGregorian::isLunar
virtual bool isLunar() const
Returns whether the calendar is lunar based.
Definition: kcalendarsystemgregorian.cpp:486
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::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
KCalendarSystemGregorian::isLunisolar
virtual bool isLunisolar() const
Returns whether the calendar is lunisolar based.
Definition: kcalendarsystemgregorian.cpp:491
KCalendarSystemMinguo
Definition: kcalendarsystemminguo_p.h:39
KCalendarSystemMinguo::isSolar
virtual bool isSolar() const
Returns whether the calendar is solar based.
Definition: kcalendarsystemminguo.cpp:179
KCalendarSystemMinguo::earliestValidDate
virtual QDate earliestValidDate() const
Returns the earliest date valid in this calendar system implementation.
Definition: kcalendarsystemminguo.cpp:112
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
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
KCalendarSystemMinguo::epoch
virtual QDate epoch() const
Returns a QDate holding the epoch of the calendar system.
Definition: kcalendarsystemminguo.cpp:106
KCalendarSystemMinguo::isLunisolar
virtual bool isLunisolar() const
Returns whether the calendar is lunisolar based.
Definition: kcalendarsystemminguo.cpp:174
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
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
KCalendarSystemMinguo::~KCalendarSystemMinguo
virtual ~KCalendarSystemMinguo()
Definition: kcalendarsystemminguo.cpp:97
KCalendarSystemMinguo::isProleptic
virtual bool isProleptic() const
Returns whether the calendar system is proleptic, i.e.
Definition: kcalendarsystemminguo.cpp:184
KCalendarSystemMinguo::weekDayName
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const
Gets specific calendar type week day name.
Definition: kcalendarsystemminguo.cpp:154
KCalendarSystemMinguo::isLunar
virtual bool isLunar() const
Returns whether the calendar is lunar based.
Definition: kcalendarsystemminguo.cpp:169
KCalendarSystemMinguo::weekDayOfPray
virtual int weekDayOfPray() const
Definition: kcalendarsystemminguo.cpp:164
KCalendarSystemMinguo::latestValidDate
virtual QDate latestValidDate() const
Returns the latest date valid in this calendar system implementation.
Definition: kcalendarsystemminguo.cpp:117
KCalendarSystemMinguo::calendarType
virtual QString calendarType() const
Definition: kcalendarsystemminguo.cpp:101
KCalendarSystemPrivate::q
const KCalendarSystem * q
Definition: kcalendarsystemprivate_p.h:104
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
KCalendarSystem::year
virtual int year(const QDate &date) const
Returns the year portion of a given date in the current calendar system.
Definition: kcalendarsystem.cpp:1331
KCalendarSystem::MonthNameFormat
MonthNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:55
KCalendarSystem::WeekDayNameFormat
WeekDayNameFormat
Format for returned month / day name.
Definition: kcalendarsystem.h:66
KCalendarSystem::month
virtual int month(const QDate &date) const
Returns the month portion of a given date in the current calendar system.
Definition: kcalendarsystem.cpp:1344
KCalendarSystem::KCalendarSystemMinguo
friend class KCalendarSystemMinguo
Definition: kcalendarsystem.h:1674
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:70
KLocale::CalendarSystem
CalendarSystem
Definition: klocale.h:780
KLocale::MinguoCalendar
@ MinguoCalendar
Minguo Calendar, aka ROC, Republic of China or Taiwanese.
Definition: klocale.h:802
KSharedConfig
KConfig variant using shared memory.
Definition: ksharedconfig.h:41
KSharedPtr< KSharedConfig >
QString
kcalendarsystemgregorianprivate_p.h
kcalendarsystemminguo_p.h
kdebug.h
klocale.h
i18nc
QString i18nc(const char *ctxt, const char *text)
Returns a localized version of a string and a context.
Definition: klocalizedstring.h:797
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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.14.38 API Reference

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