summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-07 01:12:08 (UTC)
committer ulf69 <ulf69>2004-10-07 01:12:08 (UTC)
commitf1eb5b74c962909851607c4b4cb05ee18a347d37 (patch) (side-by-side diff)
treefa98d9fc97e5d75810936917dc6c6039e7c79b45
parentf434ef382b60c1a420dd0e037d119d082e478491 (diff)
downloadkdepimpi-f1eb5b74c962909851607c4b4cb05ee18a347d37.zip
kdepimpi-f1eb5b74c962909851607c4b4cb05ee18a347d37.tar.gz
kdepimpi-f1eb5b74c962909851607c4b4cb05ee18a347d37.tar.bz2
added easy to use method to read Date with certain format
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp17
-rw-r--r--microkde/kdecore/klocale.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 17031c7..8b4513e 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -595,48 +595,65 @@ QDateTime KLocale::readDateTime(const QString &intstr,
QString date = intstr.left(pos);
QString time = intstr.mid(pos+1);
QString dformat = dateFormat(intIntDateFormat);
QString tformat = timeFormat(intIntDateFormat);
QDate m_date = readDate(date, dformat, &ok1);
QTime m_time = readTime(time, tformat, &ok2);
if (ok)
{
if ((ok1 == false) || (ok2 == false))
*ok = false;
else
*ok = true;
}
QDateTime m_dt;
m_dt.setDate(m_date);
m_dt.setTime(m_time);
qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
return m_dt;
}
+QDate KLocale::readDate(const QString &intstr,
+ IntDateFormat intIntDateFormat,
+ bool* ok) const
+{
+ bool ok1;
+
+ QString dformat = dateFormat(intIntDateFormat);
+
+ QDate m_date = readDate(intstr, dformat, &ok1);
+
+ if (ok)
+ *ok = ok1;
+
+ //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
+ return m_date;
+}
+
bool KLocale::use12Clock() const
{
return !mHourF24Format ;;
}
bool KLocale::weekStartsMonday() const
{
return mWeekStartsMonday;
}
int KLocale::weekStartDay() const
{
if ( mWeekStartsMonday )
return 1;
return 7;
}
QString KLocale::weekDayName(int i,bool shortName) const
{
if ( shortName )
switch ( i )
{
case 1: return i18n("Monday", "Mon");
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index 949301a..5783530 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -32,48 +32,50 @@ class KLocale
QString formatNumber(const QString &numStr) const;
double readNumber(const QString &numStr, bool * ok = 0) const;
QString decimalSymbol() const;
QString thousandsSeparator() const;
QString positiveSign() const;
QString negativeSign() const;
QString translate( const char *index ) const;
QString translate( const char *index, const char *fallback) const;
enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const;
QString formatDateTime(const QDateTime &pDateTime,
bool shortFormat,
bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
QDate readDate(const QString &str, bool* ok = 0) const;
QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
QTime readTime(const QString &str, bool* ok = 0) const;
+ QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
+
QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
bool use12Clock() const;
bool weekStartsMonday() const;
int weekStartDay() const;
QString weekDayName(int,bool=false) const;
QString monthName(int,bool=false) const;
QString country() const;
QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
void insertCatalogue ( const QString & );
KCalendarSystem *calendar();
void setHore24Format ( bool );
void setWeekStartMonday( bool );
void setIntDateFormat( IntDateFormat );
void setIntTimeFormat( IntDateFormat );
IntDateFormat getIntDateFormat( );
IntDateFormat getIntTimeFormat( );