summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore
authorulf69 <ulf69>2004-09-29 06:14:36 (UTC)
committer ulf69 <ulf69>2004-09-29 06:14:36 (UTC)
commit72b990edf0191c2e86204308ce2cac07120284bf (patch) (unidiff)
tree67840eda5450e7b3bc19fd181b48e5c981df96b3 /microkde/kdecore
parentf7810320ed36a03c96d00436f6b589b9b5ca8c30 (diff)
downloadkdepimpi-72b990edf0191c2e86204308ce2cac07120284bf.zip
kdepimpi-72b990edf0191c2e86204308ce2cac07120284bf.tar.gz
kdepimpi-72b990edf0191c2e86204308ce2cac07120284bf.tar.bz2
support for ISODate parsing
Diffstat (limited to 'microkde/kdecore') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp44
-rw-r--r--microkde/kdecore/klocale.h1
2 files changed, 34 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
@@ -581,4 +581,2 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
581QDateTime KLocale::readDateTime(const QString &intstr, 581QDateTime KLocale::readDateTime(const QString &intstr,
582 bool shortFormat,
583 bool includeSeconds,
584 IntDateFormat intIntDateFormat, 582 IntDateFormat intIntDateFormat,
@@ -588,7 +586,32 @@ QDateTime KLocale::readDateTime(const QString &intstr,
588 586
589 QDate m_date = readDate(date, &ok1); 587 // AT the moment we can not read any other format then ISODate
590 QTime m_time = KGlobal::locale()->readTime(time, &ok2); 588 if ( intIntDateFormat != ISODate )
591 if ((ok1 == false) || (ok2 == false)) 589 {
592 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); 590 qDebug("KLocale::readDateTime, only ISODate is supported.");
591 return QDateTime();
592 }
593
594 int pos = intstr.find("T");
595 QString date = intstr.left(pos);
596 QString time = intstr.mid(pos+1);
593 597
598 QString dformat = dateFormat(intIntDateFormat);
599 QString tformat = timeFormat(intIntDateFormat);
600
601 QDate m_date = readDate(date, dformat, &ok1);
602 QTime m_time = readTime(time, tformat, &ok2);
603
604 if (ok)
605 {
606 if ((ok1 == false) || (ok2 == false))
607 *ok = false;
608 else
609 *ok = true;
610 }
611 QDateTime m_dt;
612 m_dt.setDate(m_date);
613 m_dt.setTime(m_time);
614
615 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);
616 return m_dt;
594} 617}
@@ -688,2 +711,5 @@ QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
688 711
712 if ( dformat == ISODate )
713 return "%Y-%m-%d";
714
689 if ( QApplication::desktop()->width() < 480 ) { 715 if ( QApplication::desktop()->width() < 480 ) {
@@ -693,6 +719,3 @@ QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
693 return "%a %b %d %Y"; 719 return "%a %b %d %Y";
694 else if ( dformat == ISODate )
695 return "%a %Y %b %d";
696 } else { 720 } else {
697
698 if ( dformat == Default ) 721 if ( dformat == Default )
@@ -701,4 +724,3 @@ QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
701 return "%A %B %d %Y"; 724 return "%A %B %d %Y";
702 else if ( dformat == ISODate ) 725
703 return "%A %Y %B %d";
704 } 726 }
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index 153b12a..949301a 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -55,2 +55,3 @@ class KLocale
55 QTime readTime(const QString &str, bool* ok = 0) const; 55 QTime readTime(const QString &str, bool* ok = 0) const;
56 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
56 57