summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-03-28 23:39:37 (UTC)
committer zautrix <zautrix>2005-03-28 23:39:37 (UTC)
commit4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (patch) (unidiff)
tree6815e055d6cb35d56d43f036261f5be9d2a9c350 /microkde
parent4034290f894ff7d1b0cf1197078e0ed832566bb7 (diff)
downloadkdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.zip
kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.gz
kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.bz2
montview sunday fix
Diffstat (limited to 'microkde') (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
@@ -247,48 +247,85 @@ KLocale::IntDateFormat KLocale::getIntTimeFormat( )
247} 247}
248void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) 248void KLocale::setIntTimeFormat( KLocale::IntDateFormat i )
249{ 249{
250 mIntTimeFormat = i; 250 mIntTimeFormat = i;
251} 251}
252 252
253void KLocale::setLanguage( int i ) 253void KLocale::setLanguage( int i )
254{ 254{
255 mLanguage = i; 255 mLanguage = i;
256} 256}
257int KLocale::language( ) 257int KLocale::language( )
258{ 258{
259 return mLanguage; 259 return mLanguage;
260} 260}
261QString KLocale::translate( const char *index ) const 261QString KLocale::translate( const char *index ) const
262{ 262{
263 return i18n( index ); 263 return i18n( index );
264} 264}
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
277 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; 314 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30];
278 315
279 uint index = 0; 316 uint index = 0;
280 bool escape = false; 317 bool escape = false;
281 int number = 0; 318 int number = 0;
282 319
283 for ( uint format_index = 0; format_index < rst.length(); format_index++ ) 320 for ( uint format_index = 0; format_index < rst.length(); format_index++ )
284 { 321 {
285 if ( !escape ) 322 if ( !escape )
286 { 323 {
287 if ( rst.at( format_index ).unicode() == '%' ) 324 if ( rst.at( format_index ).unicode() == '%' )
288 escape = true; 325 escape = true;
289 else 326 else
290 buffer[index++] = rst.at( format_index ); 327 buffer[index++] = rst.at( format_index );
291 } 328 }
292 else 329 else
293 { 330 {
294 switch ( rst.at( format_index ).unicode() ) 331 switch ( rst.at( format_index ).unicode() )
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
@@ -44,49 +44,49 @@ class KLocale
44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; 44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
45 45
46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; 46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; 48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const;
49 QString formatDateTime(const QDateTime &pDateTime, 49 QString formatDateTime(const QDateTime &pDateTime,
50 bool shortFormat, 50 bool shortFormat,
51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
52 52
53 QDate readDate(const QString &str, bool* ok = 0) const; 53 QDate readDate(const QString &str, bool* ok = 0) const;
54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; 54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
55 QTime readTime(const QString &str, bool* ok = 0) const; 55 QTime readTime(const QString &str, bool* ok = 0) const;
56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
57 57
58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
59 59
60 bool use12Clock() const; 60 bool use12Clock() const;
61 bool weekStartsMonday() const; 61 bool weekStartsMonday() const;
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
75 KCalendarSystem *calendar(); 75 KCalendarSystem *calendar();
76 void setHore24Format ( bool ); 76 void setHore24Format ( bool );
77 void setWeekStartMonday( bool ); 77 void setWeekStartMonday( bool );
78 void setIntDateFormat( IntDateFormat ); 78 void setIntDateFormat( IntDateFormat );
79 void setIntTimeFormat( IntDateFormat ); 79 void setIntTimeFormat( IntDateFormat );
80 IntDateFormat getIntDateFormat( ); 80 IntDateFormat getIntDateFormat( );
81 IntDateFormat getIntTimeFormat( ); 81 IntDateFormat getIntTimeFormat( );
82 void setLanguage( int ); 82 void setLanguage( int );
83 int language(); 83 int language();
84 void setDateFormat( QString ); 84 void setDateFormat( QString );
85 void setDateFormatShort( QString ); 85 void setDateFormatShort( QString );
86 86
87 QString m_decimalSymbol; 87 QString m_decimalSymbol;
88 QString m_thousandsSeparator; 88 QString m_thousandsSeparator;
89 QString m_currencySymbol; 89 QString m_currencySymbol;
90 QString m_monetaryDecimalSymbol; 90 QString m_monetaryDecimalSymbol;
91 QString m_monetaryThousandsSeparator; 91 QString m_monetaryThousandsSeparator;
92 QString m_positiveSign; 92 QString m_positiveSign;