author | zautrix <zautrix> | 2005-03-28 23:39:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-28 23:39:37 (UTC) |
commit | 4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (patch) (side-by-side diff) | |
tree | 6815e055d6cb35d56d43f036261f5be9d2a9c350 /microkde/kdecore | |
parent | 4034290f894ff7d1b0cf1197078e0ed832566bb7 (diff) | |
download | kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.zip kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.gz kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.bz2 |
montview sunday fix
-rw-r--r-- | microkde/kdecore/klocale.cpp | 37 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 2 |
2 files changed, 38 insertions, 1 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 7f31ab1..1d8ae9f 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -268,6 +268,43 @@ QString KLocale::translate( const char *, const char *fallback) const return i18n( fallback ); } +int KLocale::weekNum ( const QDate & date ) +{ + QDate seda = date; + int weekNum = 0; + int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4 + int daystoprevthursday = (dayofweek + 3) % 7 ; + int dayofyear = seda.dayOfYear(); + int prevThursday = dayofyear - ( daystoprevthursday ); + int subweeknum = 0; + if ( prevThursday < 1 ) { + seda = seda.addDays( - daystoprevthursday ); + dayofyear = seda.dayOfYear(); + prevThursday = dayofyear; + subweeknum = prevThursday / 7; + if ( prevThursday % 7 != 0 ) + ++subweeknum; + } else { + if ( dayofyear >= 360 ) { //maybe week 1 + seda = seda.addDays( 7 - daystoprevthursday ); + dayofyear = seda.dayOfYear(); + if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) ) + return 1; + } + } + if ( ! weekNum ) { + weekNum = prevThursday / 7; + if ( prevThursday % 7 != 0 ) + ++weekNum; + if ( dayofweek < 4 ) + ++weekNum; + else if ( dayofweek == 7 && !mWeekStartsMonday ) + ++weekNum; + if ( weekNum > subweeknum ) + weekNum -= subweeknum; + } + return weekNum; +} QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const { const QString rst = timeFormat(intIntDateFormat); diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h index 14660d6..58e0b39 100644 --- a/microkde/kdecore/klocale.h +++ b/microkde/kdecore/klocale.h @@ -65,7 +65,7 @@ class KLocale QString monthName(int,bool=false) const; QString country() const; - + int weekNum ( const QDate & ); QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; |