author | ulf69 <ulf69> | 2004-10-18 03:01:17 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-18 03:01:17 (UTC) |
commit | 1712d92ea25b220273859d985bc7211fa7a97a39 (patch) (side-by-side diff) | |
tree | 00b603af10b0da8d757ffec5c29f73953fbf03e0 | |
parent | 2fd3f09238a624b1a91793d43b5f3653e2b34763 (diff) | |
download | kdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.zip kdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.tar.gz kdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.tar.bz2 |
return a real empty value in readDateTime
-rw-r--r-- | microkde/kdecore/klocale.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 8b4513e..27acfec 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -318,50 +318,54 @@ QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } QString KLocale::formatDateTime(const QDateTime &pDateTime, bool shortFormat, bool includeSeconds, IntDateFormat intIntDateFormat) const { QString format("%1 %2"); if ( intIntDateFormat == Default ) format = "%1 %2"; else if ( intIntDateFormat == Format1 ) format = "%1 %2"; else if ( intIntDateFormat == ISODate ) format = "%1T%2"; - return format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) + QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); + + //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); + + return res; } QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const { return formatDateTime(pDateTime, true, true, intIntDateFormat); } QDate KLocale::readDate(const QString &intstr, bool* ok) const { QDate date; date = readDate(intstr, true, ok); if (date.isValid()) return date; return readDate(intstr, false, ok); } QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const { QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); return readDate( intstr, fmt, ok ); } QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const { //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; @@ -580,60 +584,66 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const QDateTime KLocale::readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const { bool ok1, ok2; // 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); + QDateTime m_dt; + 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); + //only set values if both operations returned true. + if ((ok1 == true) && (ok2 == true)) + { + 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 ;; |