kcalendarsystem.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
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() == 1 )
00082     sResult.prepend('0');
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 }
 
This file is part of the documentation for kdecore Library Version 3.2.0.