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

KDECore

  • kdecore
  • date
kcalendarsystemjapanese.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2009, 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 "kcalendarsystemjapanese_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 KCalendarSystemJapanesePrivate : public KCalendarSystemGregorianPrivate
30 {
31 public:
32  explicit KCalendarSystemJapanesePrivate(KCalendarSystemJapanese *q);
33  virtual ~KCalendarSystemJapanesePrivate();
34 
35  virtual KLocale::CalendarSystem calendarSystem() const;
36  virtual void loadDefaultEraList();
37  virtual int earliestValidYear() const;
38 };
39 
40 //Override only a few of the Gregorian private methods
41 
42 KCalendarSystemJapanesePrivate::KCalendarSystemJapanesePrivate(KCalendarSystemJapanese *q)
43  : KCalendarSystemGregorianPrivate(q)
44 {
45 }
46 
47 KCalendarSystemJapanesePrivate::~KCalendarSystemJapanesePrivate()
48 {
49 }
50 
51 KLocale::CalendarSystem KCalendarSystemJapanesePrivate::calendarSystem() const
52 {
53  return KLocale::JapaneseCalendar;
54 }
55 
56 void KCalendarSystemJapanesePrivate::loadDefaultEraList()
57 {
58  QString name, shortName, format;
59 
60  // Nengō, Only do most recent for now, use AD for the rest.
61  // Feel free to add more, but have mercy on the translators :-)
62 
63  name = i18nc("Calendar Era: Gregorian Christian Era, years > 0, LongFormat", "Anno Domini");
64  shortName = i18nc("Calendar Era: Gregorian Christian Era, years > 0, ShortFormat", "AD");
65  format = i18nc("(kdedt-format) Gregorian, AD, full era year format used for %EY, e.g. 2000 AD", "%Ey %EC");
66  addEra('+', 1, q->epoch(), 1, QDate(1868, 9, 7), name, shortName, format);
67 
68  name = i18nc("Calendar Era: Japanese Nengō, Meiji Era, LongFormat", "Meiji");
69  shortName = name;
70  format = i18nc("(kdedt-format) Japanese, Meiji, full era year format used for %EY, year = 1, e.g. Meiji 1", "%EC Gannen");
71  addEra('+', 1, QDate(1868, 9, 8), 1868, QDate(1868, 12, 31), name, shortName, format);
72  format = i18nc("(kdedt-format) Japanese, Meiji, full era year format used for %EY, year > 1, e.g. Meiji 22", "%EC %Ey");
73  addEra('+', 2, QDate(1869, 1, 1), 1869, QDate(1912, 7, 29), name, shortName, format);
74 
75  name = i18nc("Calendar Era: Japanese Nengō, Taishō Era, LongFormat", "Taishō");
76  shortName = name;
77  format = i18nc("(kdedt-format) Japanese, Taishō, full era year format used for %EY, year = 1, e.g. Taishō 1", "%EC Gannen");
78  addEra('+', 1, QDate(1912, 7, 30), 1912, QDate(1912, 12, 31), name, shortName, format);
79  format = i18nc("(kdedt-format) Japanese, Taishō, full era year format used for %EY, year > 1, e.g. Taishō 22", "%EC %Ey");
80  addEra('+', 2, QDate(1913, 1, 1), 1913, QDate(1926, 12, 24), name, shortName, format);
81 
82  name = i18nc("Calendar Era: Japanese Nengō, Shōwa Era, LongFormat", "Shōwa");
83  shortName = name;
84  format = i18nc("(kdedt-format) Japanese, Shōwa, full era year format used for %EY, year = 1, e.g. Shōwa 1", "%EC Gannen");
85  addEra('+', 1, QDate(1926, 12, 25), 1926, QDate(1926, 12, 31), name, shortName, format);
86  format = i18nc("(kdedt-format) Japanese, Shōwa, full era year format used for %EY, year > 1, e.g. Shōwa 22", "%EC %Ey");
87  addEra('+', 2, QDate(1927, 1, 1), 1927, QDate(1989, 1, 7), name, shortName, format);
88 
89  name = i18nc("Calendar Era: Japanese Nengō, Heisei Era, LongFormat", "Heisei");
90  shortName = name;
91  format = i18nc("(kdedt-format) Japanese, Heisei, full era year format used for %EY, year = 1, e.g. Heisei 1", "%EC Gannen");
92  addEra('+', 1, QDate(1989, 1, 8), 1989, QDate(1989, 12, 31), name, shortName, format);
93  format = i18nc("(kdedt-format) Japanese, Heisei, full era year format used for %EY, year > 1, e.g. Heisei 22", "%EC %Ey");
94  addEra('+', 2, QDate(1990, 1, 1), 1990, q->latestValidDate(), name, shortName, format);
95 }
96 
97 int KCalendarSystemJapanesePrivate::earliestValidYear() const
98 {
99  return 1;
100 }
101 
102 
103 KCalendarSystemJapanese::KCalendarSystemJapanese(const KLocale *locale)
104  : KCalendarSystemGregorian(*new KCalendarSystemJapanesePrivate(this), KSharedConfig::Ptr(), locale)
105 {
106  d_ptr->loadConfig(calendarType());
107 }
108 
109 KCalendarSystemJapanese::KCalendarSystemJapanese(const KSharedConfig::Ptr config, const KLocale *locale)
110  : KCalendarSystemGregorian(*new KCalendarSystemJapanesePrivate(this), config, locale)
111 {
112  d_ptr->loadConfig(calendarType());
113 }
114 
115 KCalendarSystemJapanese::KCalendarSystemJapanese(KCalendarSystemJapanesePrivate &dd,
116  const KSharedConfig::Ptr config, const KLocale *locale)
117  : KCalendarSystemGregorian(dd, config, locale)
118 {
119  d_ptr->loadConfig(calendarType());
120 }
121 
122 KCalendarSystemJapanese::~KCalendarSystemJapanese()
123 {
124 }
125 
126 QString KCalendarSystemJapanese::calendarType() const
127 {
128  return QLatin1String("japanese");
129 }
130 
131 QDate KCalendarSystemJapanese::epoch() const
132 {
133  // 0001-01-01 Gregorian for now
134  return QDate::fromJulianDay(1721426);
135 }
136 
137 QDate KCalendarSystemJapanese::earliestValidDate() const
138 {
139  // 0001-01-01 Gregorian for now
140  return QDate::fromJulianDay(1721426);
141 }
142 
143 QDate KCalendarSystemJapanese::latestValidDate() const
144 {
145  // Set to last day of year 9999 until confirm date formats & widgets support > 9999
146  // 9999-12-31 Gregorian
147  return QDate::fromJulianDay(5373484);
148 }
149 
150 bool KCalendarSystemJapanese::isValid(int year, int month, int day) const
151 {
152  return KCalendarSystemGregorian::isValid(year, month, day);
153 }
154 
155 bool KCalendarSystemJapanese::isValid(const QDate &date) const
156 {
157  return KCalendarSystemGregorian::isValid(date);
158 }
159 
160 bool KCalendarSystemJapanese::isLeapYear(int year) const
161 {
162  return KCalendarSystemGregorian::isLeapYear(year);
163 }
164 
165 bool KCalendarSystemJapanese::isLeapYear(const QDate &date) const
166 {
167  return KCalendarSystemGregorian::isLeapYear(date);
168 }
169 
170 QString KCalendarSystemJapanese::monthName(int month, int year, MonthNameFormat format) const
171 {
172  return KCalendarSystemGregorian::monthName(month, year, format);
173 }
174 
175 QString KCalendarSystemJapanese::monthName(const QDate &date, MonthNameFormat format) const
176 {
177  return KCalendarSystemGregorian::monthName(date, format);
178 }
179 
180 QString KCalendarSystemJapanese::weekDayName(int weekDay, WeekDayNameFormat format) const
181 {
182  return KCalendarSystemGregorian::weekDayName(weekDay, format);
183 }
184 
185 QString KCalendarSystemJapanese::weekDayName(const QDate &date, WeekDayNameFormat format) const
186 {
187  return KCalendarSystemGregorian::weekDayName(date, format);
188 }
189 
190 int KCalendarSystemJapanese::yearStringToInteger(const QString &sNum, int &iLength) const
191 {
192  QString gannen = i18nc("Japanese year 1 of era", "Gannen");
193  if (sNum.startsWith(gannen, Qt::CaseInsensitive)) {
194  iLength = gannen.length();
195  return 1;
196  } else {
197  return KCalendarSystemGregorian::yearStringToInteger(sNum, iLength);
198  }
199 }
200 
201 int KCalendarSystemJapanese::weekDayOfPray() const
202 {
203  return 7; // TODO JPL ???
204 }
205 
206 bool KCalendarSystemJapanese::isLunar() const
207 {
208  return KCalendarSystemGregorian::isLunar();
209 }
210 
211 bool KCalendarSystemJapanese::isLunisolar() const
212 {
213  return KCalendarSystemGregorian::isLunisolar();
214 }
215 
216 bool KCalendarSystemJapanese::isSolar() const
217 {
218  return KCalendarSystemGregorian::isSolar();
219 }
220 
221 bool KCalendarSystemJapanese::isProleptic() const
222 {
223  return false;
224 }
225 
226 bool KCalendarSystemJapanese::julianDayToDate(int jd, int &year, int &month, int &day) const
227 {
228  return KCalendarSystemGregorian::julianDayToDate(jd, year, month, day);
229 }
230 
231 bool KCalendarSystemJapanese::dateToJulianDay(int year, int month, int day, int &jd) const
232 {
233  return KCalendarSystemGregorian::dateToJulianDay(year, month, day, jd);
234 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Jul 16 2013 11:43:28 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.5 API Reference

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