Diffstat (limited to 'microkde/kdecore/klocale.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdecore/klocale.cpp | 51 |
1 files changed, 41 insertions, 10 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 | |||
@@ -87,6 +87,7 @@ KLocale::KLocale() : mCalendarSystem( 0 ) | |||
87 | mWeekStartsMonday = true; | 87 | mWeekStartsMonday = true; |
88 | mHourF24Format = true; | 88 | mHourF24Format = true; |
89 | mIntDateFormat = Default; | 89 | mIntDateFormat = Default; |
90 | mIntTimeFormat = Default; | ||
90 | mLanguage = 0; | 91 | mLanguage = 0; |
91 | mDateFormat = "%a %Y %b %d"; | 92 | mDateFormat = "%a %Y %b %d"; |
92 | mDateFormatShort = "%Y-%m-%d"; | 93 | mDateFormatShort = "%Y-%m-%d"; |
@@ -139,6 +140,7 @@ void KLocale::setWeekStartMonday( bool b ) | |||
139 | { | 140 | { |
140 | mWeekStartsMonday = b; | 141 | mWeekStartsMonday = b; |
141 | } | 142 | } |
143 | |||
142 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) | 144 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) |
143 | { | 145 | { |
144 | return mIntDateFormat; | 146 | return mIntDateFormat; |
@@ -148,6 +150,16 @@ void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) | |||
148 | { | 150 | { |
149 | mIntDateFormat = i; | 151 | mIntDateFormat = i; |
150 | } | 152 | } |
153 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) | ||
154 | { | ||
155 | return mIntTimeFormat; | ||
156 | |||
157 | } | ||
158 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) | ||
159 | { | ||
160 | mIntTimeFormat = i; | ||
161 | } | ||
162 | |||
151 | void KLocale::setLanguage( int i ) | 163 | void KLocale::setLanguage( int i ) |
152 | { | 164 | { |
153 | mLanguage = i; | 165 | mLanguage = i; |
@@ -162,9 +174,9 @@ QString KLocale::translate( const char *, const char *fallback) const | |||
162 | return i18n( fallback ); | 174 | return i18n( fallback ); |
163 | } | 175 | } |
164 | 176 | ||
165 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const | 177 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const |
166 | { | 178 | { |
167 | const QString rst = timeFormat(); | 179 | const QString rst = timeFormat(intIntDateFormat); |
168 | 180 | ||
169 | // only "pm/am" here can grow, the rest shrinks, but | 181 | // only "pm/am" here can grow, the rest shrinks, but |
170 | // I'm rather safe than sorry | 182 | // I'm rather safe than sorry |
@@ -315,16 +327,17 @@ QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat | |||
315 | 327 | ||
316 | QString KLocale::formatDateTime(const QDateTime &pDateTime, | 328 | QString KLocale::formatDateTime(const QDateTime &pDateTime, |
317 | bool shortFormat, | 329 | bool shortFormat, |
318 | bool includeSeconds) const | 330 | bool includeSeconds, |
331 | IntDateFormat intIntDateFormat) const | ||
319 | { | 332 | { |
320 | return QString( "%1 %2") | 333 | return QString( "%1 %2") |
321 | .arg( formatDate( pDateTime.date(), shortFormat ) ) | 334 | .arg( formatDate( pDateTime.date(), shortFormat, intIntDateFormat ) ) |
322 | .arg( formatTime( pDateTime.time(), includeSeconds ) ); | 335 | .arg( formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ) ); |
323 | } | 336 | } |
324 | 337 | ||
325 | QString KLocale::formatDateTime(const QDateTime &pDateTime) const | 338 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const |
326 | { | 339 | { |
327 | return formatDateTime(pDateTime, true); | 340 | return formatDateTime(pDateTime, true, intIntDateFormat); |
328 | } | 341 | } |
329 | 342 | ||
330 | QDate KLocale::readDate(const QString &intstr, bool* ok) const | 343 | QDate KLocale::readDate(const QString &intstr, bool* ok) const |
@@ -456,6 +469,7 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | |||
456 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); | 469 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); |
457 | 470 | ||
458 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds | 471 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds |
472 | |||
459 | bool g_12h = false; | 473 | bool g_12h = false; |
460 | bool pm = false; | 474 | bool pm = false; |
461 | uint strpos = 0; | 475 | uint strpos = 0; |
@@ -682,11 +696,28 @@ QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const | |||
682 | } | 696 | } |
683 | 697 | ||
684 | 698 | ||
685 | QString KLocale::timeFormat() const | 699 | QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const |
686 | { | 700 | { |
687 | if ( mHourF24Format) | 701 | const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; |
702 | |||
703 | if ( tformat == Default ) | ||
704 | if ( mHourF24Format) | ||
705 | return "%H:%M:%S"; | ||
706 | else | ||
707 | return "%I:%M:%S%p"; | ||
708 | |||
709 | else if ( tformat == Format1 ) | ||
710 | if ( mHourF24Format) | ||
711 | return "%H:%M:%S"; | ||
712 | else | ||
713 | return "%I:%M:%S%p"; | ||
714 | |||
715 | else if ( tformat == ISODate ) // = Qt::ISODate | ||
716 | if ( mHourF24Format) | ||
688 | return "%H:%M:%S"; | 717 | return "%H:%M:%S"; |
689 | return "%I:%M:%S%p"; | 718 | else |
719 | return "%I:%M:%S%p"; | ||
720 | |||
690 | } | 721 | } |
691 | 722 | ||
692 | void KLocale::insertCatalogue ( const QString & ) | 723 | void KLocale::insertCatalogue ( const QString & ) |