summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore/klocale.cpp
Unidiff
Diffstat (limited to 'microkde/kdecore/klocale.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp37
1 files changed, 37 insertions, 0 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
@@ -265,12 +265,49 @@ QString KLocale::translate( const char *index ) const
265 265
266QString KLocale::translate( const char *, const char *fallback) const 266QString KLocale::translate( const char *, const char *fallback) const
267{ 267{
268 return i18n( fallback ); 268 return i18n( fallback );
269} 269}
270 270
271int KLocale::weekNum ( const QDate & date )
272{
273 QDate seda = date;
274 int weekNum = 0;
275 int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4
276 int daystoprevthursday = (dayofweek + 3) % 7 ;
277 int dayofyear = seda.dayOfYear();
278 int prevThursday = dayofyear - ( daystoprevthursday );
279 int subweeknum = 0;
280 if ( prevThursday < 1 ) {
281 seda = seda.addDays( - daystoprevthursday );
282 dayofyear = seda.dayOfYear();
283 prevThursday = dayofyear;
284 subweeknum = prevThursday / 7;
285 if ( prevThursday % 7 != 0 )
286 ++subweeknum;
287 } else {
288 if ( dayofyear >= 360 ) { //maybe week 1
289 seda = seda.addDays( 7 - daystoprevthursday );
290 dayofyear = seda.dayOfYear();
291 if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) )
292 return 1;
293 }
294 }
295 if ( ! weekNum ) {
296 weekNum = prevThursday / 7;
297 if ( prevThursday % 7 != 0 )
298 ++weekNum;
299 if ( dayofweek < 4 )
300 ++weekNum;
301 else if ( dayofweek == 7 && !mWeekStartsMonday )
302 ++weekNum;
303 if ( weekNum > subweeknum )
304 weekNum -= subweeknum;
305 }
306 return weekNum;
307}
271QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const 308QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const
272{ 309{
273 const QString rst = timeFormat(intIntDateFormat); 310 const QString rst = timeFormat(intIntDateFormat);
274 311
275 // only "pm/am" here can grow, the rest shrinks, but 312 // only "pm/am" here can grow, the rest shrinks, but
276 // I'm rather safe than sorry 313 // I'm rather safe than sorry