summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-18 03:01:17 (UTC)
committer ulf69 <ulf69>2004-10-18 03:01:17 (UTC)
commit1712d92ea25b220273859d985bc7211fa7a97a39 (patch) (unidiff)
tree00b603af10b0da8d757ffec5c29f73953fbf03e0
parent2fd3f09238a624b1a91793d43b5f3653e2b34763 (diff)
downloadkdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.zip
kdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.tar.gz
kdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.tar.bz2
return a real empty value in readDateTime
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp20
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
318 break; 318 break;
319 } 319 }
320 escape = false; 320 escape = false;
321 } 321 }
322 } 322 }
323 QString ret( buffer, index ); 323 QString ret( buffer, index );
324 delete [] buffer; 324 delete [] buffer;
325 return ret; 325 return ret;
326} 326}
327 327
328QString KLocale::formatDateTime(const QDateTime &pDateTime, 328QString KLocale::formatDateTime(const QDateTime &pDateTime,
329 bool shortFormat, 329 bool shortFormat,
330 bool includeSeconds, 330 bool includeSeconds,
331 IntDateFormat intIntDateFormat) const 331 IntDateFormat intIntDateFormat) const
332{ 332{
333 QString format("%1 %2"); 333 QString format("%1 %2");
334 334
335 if ( intIntDateFormat == Default ) 335 if ( intIntDateFormat == Default )
336 format = "%1 %2"; 336 format = "%1 %2";
337 else if ( intIntDateFormat == Format1 ) 337 else if ( intIntDateFormat == Format1 )
338 format = "%1 %2"; 338 format = "%1 %2";
339 else if ( intIntDateFormat == ISODate ) 339 else if ( intIntDateFormat == ISODate )
340 format = "%1T%2"; 340 format = "%1T%2";
341 341
342 return format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) 342 QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat ))
343 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); 343 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ));
344
345 //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() );
346
347 return res;
344} 348}
345 349
346QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const 350QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const
347{ 351{
348 return formatDateTime(pDateTime, true, true, intIntDateFormat); 352 return formatDateTime(pDateTime, true, true, intIntDateFormat);
349} 353}
350 354
351QDate KLocale::readDate(const QString &intstr, bool* ok) const 355QDate KLocale::readDate(const QString &intstr, bool* ok) const
352{ 356{
353 QDate date; 357 QDate date;
354 date = readDate(intstr, true, ok); 358 date = readDate(intstr, true, ok);
355 if (date.isValid()) return date; 359 if (date.isValid()) return date;
356 return readDate(intstr, false, ok); 360 return readDate(intstr, false, ok);
357} 361}
358 362
359QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const 363QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const
360{ 364{
361 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); 365 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace();
362 return readDate( intstr, fmt, ok ); 366 return readDate( intstr, fmt, ok );
363} 367}
364 368
365QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const 369QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const
366{ 370{
367 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; 371 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl;
@@ -580,60 +584,66 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
580 584
581QDateTime KLocale::readDateTime(const QString &intstr, 585QDateTime KLocale::readDateTime(const QString &intstr,
582 IntDateFormat intIntDateFormat, 586 IntDateFormat intIntDateFormat,
583 bool* ok) const 587 bool* ok) const
584{ 588{
585 bool ok1, ok2; 589 bool ok1, ok2;
586 590
587 // AT the moment we can not read any other format then ISODate 591 // AT the moment we can not read any other format then ISODate
588 if ( intIntDateFormat != ISODate ) 592 if ( intIntDateFormat != ISODate )
589 { 593 {
590 qDebug("KLocale::readDateTime, only ISODate is supported."); 594 qDebug("KLocale::readDateTime, only ISODate is supported.");
591 return QDateTime(); 595 return QDateTime();
592 } 596 }
593 597
594 int pos = intstr.find("T"); 598 int pos = intstr.find("T");
595 QString date = intstr.left(pos); 599 QString date = intstr.left(pos);
596 QString time = intstr.mid(pos+1); 600 QString time = intstr.mid(pos+1);
597 601
598 QString dformat = dateFormat(intIntDateFormat); 602 QString dformat = dateFormat(intIntDateFormat);
599 QString tformat = timeFormat(intIntDateFormat); 603 QString tformat = timeFormat(intIntDateFormat);
600 604
601 QDate m_date = readDate(date, dformat, &ok1); 605 QDate m_date = readDate(date, dformat, &ok1);
602 QTime m_time = readTime(time, tformat, &ok2); 606 QTime m_time = readTime(time, tformat, &ok2);
603 607
608 QDateTime m_dt;
609
604 if (ok) 610 if (ok)
605 { 611 {
606 if ((ok1 == false) || (ok2 == false)) 612 if ((ok1 == false) || (ok2 == false))
607 *ok = false; 613 *ok = false;
608 else 614 else
609 *ok = true; 615 *ok = true;
610 } 616 }
611 QDateTime m_dt;
612 m_dt.setDate(m_date);
613 m_dt.setTime(m_time);
614 617
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); 618 //only set values if both operations returned true.
619 if ((ok1 == true) && (ok2 == true))
620 {
621 m_dt.setDate(m_date);
622 m_dt.setTime(m_time);
623 }
624
625 //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; 626 return m_dt;
617} 627}
618 628
619QDate KLocale::readDate(const QString &intstr, 629QDate KLocale::readDate(const QString &intstr,
620 IntDateFormat intIntDateFormat, 630 IntDateFormat intIntDateFormat,
621 bool* ok) const 631 bool* ok) const
622{ 632{
623 bool ok1; 633 bool ok1;
624 634
625 QString dformat = dateFormat(intIntDateFormat); 635 QString dformat = dateFormat(intIntDateFormat);
626 636
627 QDate m_date = readDate(intstr, dformat, &ok1); 637 QDate m_date = readDate(intstr, dformat, &ok1);
628 638
629 if (ok) 639 if (ok)
630 *ok = ok1; 640 *ok = ok1;
631 641
632 //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); 642 //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);
633 return m_date; 643 return m_date;
634} 644}
635 645
636 646
637bool KLocale::use12Clock() const 647bool KLocale::use12Clock() const
638{ 648{
639 return !mHourF24Format ;; 649 return !mHourF24Format ;;