author | ulf69 <ulf69> | 2004-09-15 17:48:36 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-15 17:48:36 (UTC) |
commit | 0af70ae5fee7b71aecf5ac742fdd65e31237eb5a (patch) (side-by-side diff) | |
tree | 08a51756744591056fd74f3658afe940f5823265 /microkde/kdecore/klocale.cpp | |
parent | c151151ccaffe54510e58731dc6d8f9d441bd31c (diff) | |
download | kdepimpi-0af70ae5fee7b71aecf5ac742fdd65e31237eb5a.zip kdepimpi-0af70ae5fee7b71aecf5ac742fdd65e31237eb5a.tar.gz kdepimpi-0af70ae5fee7b71aecf5ac742fdd65e31237eb5a.tar.bz2 |
small changes to accommodate pwManager
-rw-r--r-- | microkde/kdecore/klocale.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 9d7e60b..4960b9a 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -84,12 +84,13 @@ KLocale::KLocale() : mCalendarSystem( 0 ) mWeekStartsMonday = true; mHourF24Format = true; mIntDateFormat = Default; + mIntTimeFormat = Default; mLanguage = 0; mDateFormat = "%a %Y %b %d"; mDateFormatShort = "%Y-%m-%d"; mTimeZoneList << i18n ("-11:00 US/Samoa") << i18n ("-10:00 US/Hawaii") << i18n ("-09:00 US/Alaska") @@ -136,21 +137,32 @@ void KLocale::setHore24Format ( bool b ) mHourF24Format = b; } void KLocale::setWeekStartMonday( bool b ) { mWeekStartsMonday = b; } + KLocale::IntDateFormat KLocale::getIntDateFormat( ) { return mIntDateFormat; } void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) { mIntDateFormat = i; } +KLocale::IntDateFormat KLocale::getIntTimeFormat( ) +{ + return mIntTimeFormat; + +} +void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) +{ + mIntTimeFormat = i; +} + void KLocale::setLanguage( int i ) { mLanguage = i; } QString KLocale::translate( const char *index ) const { @@ -159,15 +171,15 @@ QString KLocale::translate( const char *index ) const QString KLocale::translate( const char *, const char *fallback) const { return i18n( fallback ); } -QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const +QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const { - const QString rst = timeFormat(); + const QString rst = timeFormat(intIntDateFormat); // only "pm/am" here can grow, the rest shrinks, but // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; uint index = 0; @@ -312,22 +324,23 @@ QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat delete [] buffer; return ret; } QString KLocale::formatDateTime(const QDateTime &pDateTime, bool shortFormat, - bool includeSeconds) const + bool includeSeconds, + IntDateFormat intIntDateFormat) const { return QString( "%1 %2") - .arg( formatDate( pDateTime.date(), shortFormat ) ) - .arg( formatTime( pDateTime.time(), includeSeconds ) ); + .arg( formatDate( pDateTime.date(), shortFormat, intIntDateFormat ) ) + .arg( formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ) ); } -QString KLocale::formatDateTime(const QDateTime &pDateTime) const +QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const { - return formatDateTime(pDateTime, true); + return formatDateTime(pDateTime, true, intIntDateFormat); } QDate KLocale::readDate(const QString &intstr, bool* ok) const { QDate date; date = readDate(intstr, true, ok); @@ -453,12 +466,13 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const QString str = intstr.simplifyWhiteSpace().lower(); QString Format = timeFormat().simplifyWhiteSpace(); if (!seconds) Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds + bool g_12h = false; bool pm = false; uint strpos = 0; uint Formatpos = 0; while (Format.length() > Formatpos || str.length() > strpos) @@ -679,17 +693,34 @@ QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const return "%Y-%m-%d"; return mDateFormatShort ; } -QString KLocale::timeFormat() const +QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const { + const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; + + if ( tformat == Default ) if ( mHourF24Format) return "%H:%M:%S"; + else return "%I:%M:%S%p"; + + else if ( tformat == Format1 ) + if ( mHourF24Format) + return "%H:%M:%S"; + else + return "%I:%M:%S%p"; + + else if ( tformat == ISODate ) // = Qt::ISODate + if ( mHourF24Format) + return "%H:%M:%S"; + else + return "%I:%M:%S%p"; + } void KLocale::insertCatalogue ( const QString & ) { } |