kdecore Library API Documentation

kcalendarsystem.cpp

00001 /* 00002 Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> 00003 Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 // Gregorian calendar system implementation factory for creation of kde calendar 00022 // systems. 00023 // Also default gregorian and factory classes 00024 00025 #include <kglobal.h> 00026 00027 #include "kcalendarsystem.h" 00028 00029 class KCalendarSystemPrivate 00030 { 00031 public: 00032 const KLocale * locale; 00033 }; 00034 00035 KCalendarSystem::KCalendarSystem(const KLocale * locale) 00036 : d(new KCalendarSystemPrivate) 00037 { 00038 d->locale = locale; 00039 } 00040 00041 KCalendarSystem::~KCalendarSystem() 00042 { 00043 delete d; 00044 } 00045 00046 const KLocale * KCalendarSystem::locale() const 00047 { 00048 if ( d->locale ) 00049 return d->locale; 00050 00051 return KGlobal::locale(); 00052 } 00053 00054 QString KCalendarSystem::dayString(const QDate & pDate, bool bShort) const 00055 { 00056 QString sResult; 00057 00058 sResult.setNum(day(pDate)); 00059 if (!bShort && sResult.length() == 1 ) 00060 sResult.prepend('0'); 00061 00062 return sResult; 00063 } 00064 00065 QString KCalendarSystem::monthString(const QDate & pDate, bool bShort) const 00066 { 00067 QString sResult; 00068 00069 sResult.setNum(month(pDate)); 00070 if (!bShort && sResult.length() == 1 ) 00071 sResult.prepend('0'); 00072 00073 return sResult; 00074 } 00075 00076 QString KCalendarSystem::yearString(const QDate & pDate, bool bShort) const 00077 { 00078 QString sResult; 00079 00080 sResult.setNum(year(pDate)); 00081 if (bShort && sResult.length() == 4 ) 00082 sResult = sResult.right(2); 00083 00084 return sResult; 00085 } 00086 00087 static int stringToInteger(const QString & sNum, int & iLength) 00088 { 00089 unsigned int iPos = 0; 00090 00091 int result = 0; 00092 for (; sNum.length() > iPos && sNum.at(iPos).isDigit(); iPos++) 00093 { 00094 result *= 10; 00095 result += sNum.at(iPos).digitValue(); 00096 } 00097 00098 iLength = iPos; 00099 return result; 00100 } 00101 00102 00103 int KCalendarSystem::dayStringToInteger(const QString & sNum, int & iLength) const 00104 { 00105 return stringToInteger(sNum, iLength); 00106 } 00107 00108 int KCalendarSystem::monthStringToInteger(const QString & sNum, int & iLength) const 00109 { 00110 return stringToInteger(sNum, iLength); 00111 } 00112 00113 int KCalendarSystem::yearStringToInteger(const QString & sNum, int & iLength) const 00114 { 00115 return stringToInteger(sNum, iLength); 00116 }
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 10 18:54:54 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003