summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore/klocale.cpp
authorulf69 <ulf69>2004-09-29 06:14:36 (UTC)
committer ulf69 <ulf69>2004-09-29 06:14:36 (UTC)
commit72b990edf0191c2e86204308ce2cac07120284bf (patch) (side-by-side diff)
tree67840eda5450e7b3bc19fd181b48e5c981df96b3 /microkde/kdecore/klocale.cpp
parentf7810320ed36a03c96d00436f6b589b9b5ca8c30 (diff)
downloadkdepimpi-72b990edf0191c2e86204308ce2cac07120284bf.zip
kdepimpi-72b990edf0191c2e86204308ce2cac07120284bf.tar.gz
kdepimpi-72b990edf0191c2e86204308ce2cac07120284bf.tar.bz2
support for ISODate parsing
Diffstat (limited to 'microkde/kdecore/klocale.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 7bd8a70..17031c7 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -579,18 +579,41 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
}
QDateTime KLocale::readDateTime(const QString &intstr,
- bool shortFormat,
- bool includeSeconds,
IntDateFormat intIntDateFormat,
bool* ok) const
{
bool ok1, ok2;
- QDate m_date = readDate(date, &ok1);
- QTime m_time = KGlobal::locale()->readTime(time, &ok2);
- if ((ok1 == false) || (ok2 == false))
- qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
+ // AT the moment we can not read any other format then ISODate
+ if ( intIntDateFormat != ISODate )
+ {
+ qDebug("KLocale::readDateTime, only ISODate is supported.");
+ return QDateTime();
+ }
+
+ int pos = intstr.find("T");
+ 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;
}
@@ -686,21 +709,20 @@ QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
{
const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
+ if ( dformat == ISODate )
+ return "%Y-%m-%d";
+
if ( QApplication::desktop()->width() < 480 ) {
if ( dformat == Default )
return "%a %d %b %Y";
else if ( dformat == Format1 )
return "%a %b %d %Y";
- else if ( dformat == ISODate )
- return "%a %Y %b %d";
} else {
-
if ( dformat == Default )
return "%A %d %B %Y";
else if ( dformat == Format1 )
return "%A %B %d %Y";
- else if ( dformat == ISODate )
- return "%A %Y %B %d";
+
}
return mDateFormat ;
}