summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore
Unidiff
Diffstat (limited to 'microkde/kdecore') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp37
-rw-r--r--microkde/kdecore/klocale.h2
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
@@ -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
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
@@ -62,13 +62,13 @@ class KLocale
62 int weekStartDay() const; 62 int weekStartDay() const;
63 63
64 QString weekDayName(int,bool=false) const; 64 QString weekDayName(int,bool=false) const;
65 QString monthName(int,bool=false) const; 65 QString monthName(int,bool=false) const;
66 66
67 QString country() const; 67 QString country() const;
68 68 int weekNum ( const QDate & );
69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; 69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; 70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; 71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
72 72
73 void insertCatalogue ( const QString & ); 73 void insertCatalogue ( const QString & );
74 74