Bug 129889 - Editing Calendar Inside KPlato shows incorrect Dates
Summary: Editing Calendar Inside KPlato shows incorrect Dates
Status: RESOLVED FIXED
Alias: None
Product: kplato
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Dag Andersen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-27 05:33 UTC by Joel Webb
Modified: 2006-08-23 18:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joel Webb 2006-06-27 05:33:34 UTC
Version:           0.5.1 (using KDE 3.5.2 Level "a" , SUSE 10.0 UNSUPPORTED)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-15.10-default

The Sunday Day is in the wrong field. This could be because of the English way of looking at calendars verses European "Mondays first" way.
Comment 1 Halla Rempt 2006-08-22 10:04:15 UTC
I can confirm this: if you have set your calendar to start the week with Sunday in kcontrol, then the headings are sun to sat, but the calendar itself is still mon to sun.
Comment 2 Halla Rempt 2006-08-22 10:04:50 UTC
Btw, I'm using 1.6 svn right now, trying to use kplato for the current deathmarch project at work.
Comment 3 Dag Andersen 2006-08-23 18:30:07 UTC
SVN commit 576264 by danders:

Fix the calendar table dialog when the first day of the week is not monday.
CCBUG:129889



 M  +22 -4     kptdatetable.cc  
 M  +6 -9      kptdatetable.h  


--- branches/koffice/1.6/koffice/kplato/kptdatetable.cc #576263:576264
@@ -1,7 +1,7 @@
 /* This file is part of the KDE project
     Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
               (C) 1998-2001 Mirko Boehm (mirko@kde.org)
-              (C) 2004 Dag Andersen <danders@get2net.dk>
+              (C) 2004-2006 Dag Andersen <danders@get2net.dk>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -505,7 +505,7 @@
     }
 
     temp.setYMD(date.year(), date.month(), 1);
-    firstday=temp.dayOfWeek();
+    firstday=column(KGlobal::locale()->calendar()->dayOfWeek(temp));
     if(firstday==1) firstday=8; // Reserve row 1 for previous month
     numdays=date.daysInMonth();
     if(date.month()==1) { // set to december of previous year
@@ -541,9 +541,9 @@
     //m_selectedDates.clear();
 
     temp.setYMD(date.year(), date.month(), 1);
-    firstday=temp.dayOfWeek();
+    firstday=column(KGlobal::locale()->calendar()->dayOfWeek(temp));
     if(firstday==1) firstday=8;
-    //kdDebug()<<k_funcinfo<<"date="<<temp.toString()<<"day="<<temp.dayOfWeek()<<" firstday="<<firstday<<endl;
+    //kdDebug()<<k_funcinfo<<"date="<<temp<<"day="<<(KGlobal::locale()->calendar()->dayOfWeek(temp))<<" firstday="<<firstday<<endl;
     numdays=date.daysInMonth();
     if(date.month()==1) { // set to december of previous year
         temp.setYMD(date.year()-1, 12, 1);
@@ -654,6 +654,24 @@
     return m_markedDates[date.toString()];
 }
 
+QDate DateTable::getDate(int pos) const {
+    return QDate(date.year(), date.month(), 1).addDays(pos-firstday); 
+}
+
+int DateTable::weekday(int col) const {
+    int day = col - m_dateStartCol + KGlobal::locale()->weekStartDay();
+    if (day > 7) day %= 7;
+    //kdDebug()<<k_funcinfo<<"col="<<col<<" day="<<day<<" StartCol="<<m_dateStartCol<<" weekStartDay="<<KGlobal::locale()->weekStartDay()<<endl;
+    return day;
+}
+
+int DateTable::column(int weekday) const {
+    int col = weekday - KGlobal::locale()->weekStartDay();
+    if (col < 0) col += 7;
+    //kdDebug()<<k_funcinfo<<"col="<<col<<" day="<<col<<" StartCol="<<m_dateStartCol<<" weekStartDay="<<KGlobal::locale()->weekStartDay()<<endl;
+    return col + m_dateStartCol;
+}
+
 void DateTable::clear() {
     clearSelection();
     m_markedDates.clear();
--- branches/koffice/1.6/koffice/kplato/kptdatetable.h #576263:576264
@@ -1,7 +1,7 @@
 /* This file is part of the KDE project
     Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
               (C) 1998-2001 Mirko Boehm (mirko@kde.org)
-              (C) 2004 Dag Andersen <danders@get2net.dk>
+              (C) 2004-2006 Dag Andersen <danders@get2net.dk>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -332,20 +332,17 @@
     void updateMarkedCells();
     void updateCells();
 
-    QDate getDate(int pos) { return QDate(date.year(), date.month(), 1).addDays(pos-firstday); }
-
+    QDate getDate(int pos) const;
+    
     /**
      *  pos can be 1..42
      * row starts at 1, col depends on wether weeks are presented (in col 0)
      */
     int position(int row, int col) { return ((7 * (row - 1)) + col - m_dateStartCol + 1); }
 
-    int weekday(int col) {
-        int day = col - m_dateStartCol + KGlobal::locale()->weekStartDay();
-        if (day > 7) day %= 7;
-        return day;
-    }
-
+    int weekday(int col) const;
+    int column(int weekday) const;
+    
     void paintWeekday(QPainter *painter, int col);
     void paintWeekNumber(QPainter *painter, int row);
     void paintDay(QPainter *painter, int row, int col);
Comment 4 Dag Andersen 2006-08-23 18:32:01 UTC
*** Bug has been marked as fixed ***.