-rw-r--r-- | microkde/kdecore/klocale.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 4960b9a..7bd8a70 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -317,40 +317,48 @@ QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat | |||
317 | buffer[index++] = rst.at( format_index ); | 317 | buffer[index++] = rst.at( format_index ); |
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 | ||
328 | QString KLocale::formatDateTime(const QDateTime &pDateTime, | 328 | QString 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 | return QString( "%1 %2") | 333 | QString format("%1 %2"); |
334 | .arg( formatDate( pDateTime.date(), shortFormat, intIntDateFormat ) ) | 334 | |
335 | .arg( formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ) ); | 335 | if ( intIntDateFormat == Default ) |
336 | format = "%1 %2"; | ||
337 | else if ( intIntDateFormat == Format1 ) | ||
338 | format = "%1 %2"; | ||
339 | else if ( intIntDateFormat == ISODate ) | ||
340 | format = "%1T%2"; | ||
341 | |||
342 | return format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) | ||
343 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); | ||
336 | } | 344 | } |
337 | 345 | ||
338 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const | 346 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const |
339 | { | 347 | { |
340 | return formatDateTime(pDateTime, true, intIntDateFormat); | 348 | return formatDateTime(pDateTime, true, true, intIntDateFormat); |
341 | } | 349 | } |
342 | 350 | ||
343 | QDate KLocale::readDate(const QString &intstr, bool* ok) const | 351 | QDate KLocale::readDate(const QString &intstr, bool* ok) const |
344 | { | 352 | { |
345 | QDate date; | 353 | QDate date; |
346 | date = readDate(intstr, true, ok); | 354 | date = readDate(intstr, true, ok); |
347 | if (date.isValid()) return date; | 355 | if (date.isValid()) return date; |
348 | return readDate(intstr, false, ok); | 356 | return readDate(intstr, false, ok); |
349 | } | 357 | } |
350 | 358 | ||
351 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const | 359 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const |
352 | { | 360 | { |
353 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); | 361 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); |
354 | return readDate( intstr, fmt, ok ); | 362 | return readDate( intstr, fmt, ok ); |
355 | } | 363 | } |
356 | 364 | ||
@@ -557,32 +565,48 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | |||
557 | if (g_12h) | 565 | if (g_12h) |
558 | { | 566 | { |
559 | hour %= 12; | 567 | hour %= 12; |
560 | if (pm) hour += 12; | 568 | if (pm) hour += 12; |
561 | } | 569 | } |
562 | 570 | ||
563 | if (ok) *ok = true; | 571 | if (ok) *ok = true; |
564 | return QTime(hour, minute, second); | 572 | return QTime(hour, minute, second); |
565 | 573 | ||
566 | error: | 574 | error: |
567 | if (ok) *ok = false; | 575 | if (ok) *ok = false; |
568 | return QTime(-1, -1, -1); // return invalid date if it didn't work | 576 | return QTime(-1, -1, -1); // return invalid date if it didn't work |
569 | // This will be removed in the near future, since it gives a warning on stderr. | 577 | // This will be removed in the near future, since it gives a warning on stderr. |
570 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. | 578 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. |
571 | } | 579 | } |
572 | 580 | ||
581 | QDateTime KLocale::readDateTime(const QString &intstr, | ||
582 | bool shortFormat, | ||
583 | bool includeSeconds, | ||
584 | IntDateFormat intIntDateFormat, | ||
585 | bool* ok) const | ||
586 | { | ||
587 | bool ok1, ok2; | ||
588 | |||
589 | QDate m_date = readDate(date, &ok1); | ||
590 | QTime m_time = KGlobal::locale()->readTime(time, &ok2); | ||
591 | if ((ok1 == false) || (ok2 == false)) | ||
592 | qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); | ||
593 | |||
594 | } | ||
595 | |||
596 | |||
573 | bool KLocale::use12Clock() const | 597 | bool KLocale::use12Clock() const |
574 | { | 598 | { |
575 | return !mHourF24Format ;; | 599 | return !mHourF24Format ;; |
576 | } | 600 | } |
577 | 601 | ||
578 | bool KLocale::weekStartsMonday() const | 602 | bool KLocale::weekStartsMonday() const |
579 | { | 603 | { |
580 | return mWeekStartsMonday; | 604 | return mWeekStartsMonday; |
581 | } | 605 | } |
582 | 606 | ||
583 | int KLocale::weekStartDay() const | 607 | int KLocale::weekStartDay() const |
584 | { | 608 | { |
585 | if ( mWeekStartsMonday ) | 609 | if ( mWeekStartsMonday ) |
586 | return 1; | 610 | return 1; |
587 | return 7; | 611 | return 7; |
588 | } | 612 | } |