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) (side-by-side diff)
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) (show 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( )
}
void KLocale::setIntTimeFormat( KLocale::IntDateFormat i )
{
mIntTimeFormat = i;
}
void KLocale::setLanguage( int i )
{
mLanguage = i;
}
int KLocale::language( )
{
return mLanguage;
}
QString KLocale::translate( const char *index ) const
{
return i18n( index );
}
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);
// only "pm/am" here can grow, the rest shrinks, but
// I'm rather safe than sorry
QChar *buffer = new QChar[rst.length() * 3 / 2 + 30];
uint index = 0;
bool escape = false;
int number = 0;
for ( uint format_index = 0; format_index < rst.length(); format_index++ )
{
if ( !escape )
{
if ( rst.at( format_index ).unicode() == '%' )
escape = true;
else
buffer[index++] = rst.at( format_index );
}
else
{
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
enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const;
QString formatDateTime(const QDateTime &pDateTime,
bool shortFormat,
bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
QDate readDate(const QString &str, bool* ok = 0) const;
QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
QTime readTime(const QString &str, bool* ok = 0) const;
QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
bool use12Clock() const;
bool weekStartsMonday() const;
int weekStartDay() const;
QString weekDayName(int,bool=false) const;
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;
void insertCatalogue ( const QString & );
KCalendarSystem *calendar();
void setHore24Format ( bool );
void setWeekStartMonday( bool );
void setIntDateFormat( IntDateFormat );
void setIntTimeFormat( IntDateFormat );
IntDateFormat getIntDateFormat( );
IntDateFormat getIntTimeFormat( );
void setLanguage( int );
int language();
void setDateFormat( QString );
void setDateFormatShort( QString );
QString m_decimalSymbol;
QString m_thousandsSeparator;
QString m_currencySymbol;
QString m_monetaryDecimalSymbol;
QString m_monetaryThousandsSeparator;
QString m_positiveSign;