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

KDECore

kcalendarsystemthai.cpp
Go to the documentation of this file.
00001 /*
00002     Copyright 2009, 2010 John Layt <john@layt.net>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kcalendarsystemthai_p.h"
00021 #include "kcalendarsystemgregorianprivate_p.h"
00022 
00023 #include "kdebug.h"
00024 #include "klocale.h"
00025 
00026 #include <QtCore/QDate>
00027 
00028 //Reuse the Gregorian private implementation
00029 class KCalendarSystemThaiPrivate : public KCalendarSystemGregorianPrivate
00030 {
00031 public:
00032     explicit KCalendarSystemThaiPrivate(KCalendarSystemThai *q);
00033     virtual ~KCalendarSystemThaiPrivate();
00034 
00035     virtual KLocale::CalendarSystem calendarSystem() const;
00036     virtual void loadDefaultEraList();
00037     virtual bool isLeapYear(int year) const;
00038     virtual bool hasYearZero() const;
00039     virtual int earliestValidYear() const;
00040 };
00041 
00042 //Override only a few of the Gregorian private methods
00043 
00044 KCalendarSystemThaiPrivate::KCalendarSystemThaiPrivate(KCalendarSystemThai *q)
00045                           : KCalendarSystemGregorianPrivate(q)
00046 {
00047 }
00048 
00049 KCalendarSystemThaiPrivate::~KCalendarSystemThaiPrivate()
00050 {
00051 }
00052 
00053 KLocale::CalendarSystem KCalendarSystemThaiPrivate::calendarSystem() const
00054 {
00055     return KLocale::ThaiCalendar;
00056 }
00057 
00058 void KCalendarSystemThaiPrivate::loadDefaultEraList()
00059 {
00060     QString name, shortName, format;
00061 
00062     name = i18nc("Calendar Era: Thai Buddhist Era, years > 0, LongFormat", "Buddhist Era");
00063     shortName = i18nc("Calendar Era: Thai Buddhist Era, years > 0, ShortFormat", "BE");
00064     format = i18nc("(kdedt-format) Thai, BE, full era year format used for %EY, e.g. 2000 BE", "%Ey %EC");
00065     addEra('+', 1, q->epoch(), 1, q->latestValidDate(), name, shortName, format);
00066 }
00067 
00068 bool KCalendarSystemThaiPrivate::isLeapYear(int year) const
00069 {
00070     return KCalendarSystemGregorianPrivate::isLeapYear(year - 543);
00071 }
00072 
00073 bool KCalendarSystemThaiPrivate::hasYearZero() const
00074 {
00075     return true;
00076 }
00077 
00078 int KCalendarSystemThaiPrivate::earliestValidYear() const
00079 {
00080     return 0;
00081 }
00082 
00083 
00084 KCalendarSystemThai::KCalendarSystemThai(const KLocale *locale)
00085                    : KCalendarSystemGregorian(*new KCalendarSystemThaiPrivate(this), KSharedConfig::Ptr(), locale)
00086 {
00087     d_ptr->loadConfig(calendarType());
00088 }
00089 
00090 KCalendarSystemThai::KCalendarSystemThai(const KSharedConfig::Ptr config, const KLocale *locale)
00091                    : KCalendarSystemGregorian(*new KCalendarSystemThaiPrivate(this), config, locale)
00092 {
00093     d_ptr->loadConfig(calendarType());
00094 }
00095 
00096 KCalendarSystemThai::KCalendarSystemThai(KCalendarSystemThaiPrivate &dd,
00097                                          const KSharedConfig::Ptr config, const KLocale *locale)
00098                    : KCalendarSystemGregorian(dd, config, locale)
00099 {
00100     d_ptr->loadConfig(calendarType());
00101 }
00102 
00103 KCalendarSystemThai::~KCalendarSystemThai()
00104 {
00105 }
00106 
00107 QString KCalendarSystemThai::calendarType() const
00108 {
00109     return QLatin1String("thai");
00110 }
00111 
00112 QDate KCalendarSystemThai::epoch() const
00113 {
00114     // 0000-01-01 = 0544-01-01 BC Gregorian = 0544-01-07 BC Julian
00115     return QDate::fromJulianDay(1522734);
00116 }
00117 
00118 QDate KCalendarSystemThai::earliestValidDate() const
00119 {
00120     return epoch();
00121 }
00122 
00123 QDate KCalendarSystemThai::latestValidDate() const
00124 {
00125     // Set to last day of year 9999 until confirm date formats & widgets support > 9999
00126     // 9999-12-31 = 9456-12-31 AD Gregorian
00127     return QDate::fromJulianDay(5175158);
00128 }
00129 
00130 bool KCalendarSystemThai::isValid(int year, int month, int day) const
00131 {
00132     return KCalendarSystemGregorian::isValid(year, month, day);
00133 }
00134 
00135 bool KCalendarSystemThai::isValid(const QDate &date) const
00136 {
00137     return KCalendarSystemGregorian::isValid(date);
00138 }
00139 
00140 bool KCalendarSystemThai::isLeapYear(int year) const
00141 {
00142     return KCalendarSystemGregorian::isLeapYear(year);
00143 }
00144 
00145 bool KCalendarSystemThai::isLeapYear(const QDate &date) const
00146 {
00147     return KCalendarSystemGregorian::isLeapYear(date);
00148 }
00149 
00150 int KCalendarSystemThai::weekDayOfPray() const
00151 {
00152     return 7; // TODO JPL ???
00153 }
00154 
00155 bool KCalendarSystemThai::isLunar() const
00156 {
00157     return KCalendarSystemGregorian::isLunar();
00158 }
00159 
00160 bool KCalendarSystemThai::isLunisolar() const
00161 {
00162     return KCalendarSystemGregorian::isLunisolar();
00163 }
00164 
00165 bool KCalendarSystemThai::isSolar() const
00166 {
00167     return KCalendarSystemGregorian::isSolar();
00168 }
00169 
00170 bool KCalendarSystemThai::isProleptic() const
00171 {
00172     return false;
00173 }
00174 
00175 bool KCalendarSystemThai::julianDayToDate(int jd, int &year, int &month, int &day) const
00176 {
00177     bool result = KCalendarSystemGregorian::julianDayToDate(jd, year, month, day);
00178     year = year + 543;
00179     return result;
00180 }
00181 
00182 bool KCalendarSystemThai::dateToJulianDay(int year, int month, int day, int &jd) const
00183 {
00184     return KCalendarSystemGregorian::dateToJulianDay(year - 543, month, day, jd);
00185 }
00186 

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

Skip menu "kdelibs"
  • 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
Generated for kdelibs by doxygen 1.7.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal