[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#584150: [kdepim] Years (birthday, anniversary) are shown wrong in kdepim-apps



Package: kdepim
Version: 4:4.4.3-1
Severity: normal
Tags: patch fixed-upstream

I noticed that all birthday or anniversary years are shown wrong (off by one 
year by most events) inside kdepim apps. After checking the yearDiff function 
it should relative clear that this cannot work because this is very vague... 
actually wrong and overcomplicated.

Attached is a patch which fixes the problem. It is also included in KDE 4.4.4


--- System information. ---
Architecture: amd64
Kernel:       Linux 2.6.34-1-amd64

Debian Release: squeeze/sid
  500 unstable        ftp.uni-kl.de 
  500 unstable        ftp.debian.org 
  500 testing         ftp.debian.org 
  500 stable          ftp.debian.org 
    1 experimental    ftp.debian.org 

--- Package information. ---
Depends                        (Version) | Installed
========================================-+-===============
akregator                 (>= 4:4.4.3-1) | 4:4.4.3-1
kaddressbook              (>= 4:4.4.3-1) | 4:4.4.3-1
kalarm                    (>= 4:4.4.3-1) | 4:4.4.3-1
kdepim-kresources         (>= 4:4.4.3-1) | 4:4.4.3-1
kdepim-wizards            (>= 4:4.4.3-1) | 4:4.4.3-1
kmail                     (>= 4:4.4.3-1) | 4:4.4.3-1
knode                     (>= 4:4.4.3-1) | 4:4.4.3-1
knotes                    (>= 4:4.4.3-1) | 4:4.4.3-1
konsolekalendar           (>= 4:4.4.3-1) | 4:4.4.3-1
kontact                   (>= 4:4.4.3-1) | 4:4.4.3-1
korganizer                (>= 4:4.4.3-1) | 4:4.4.3-1
ktimetracker              (>= 4:4.4.3-1) | 4:4.4.3-1
kdepim-strigi-plugins     (>= 4:4.4.3-1) | 4:4.4.3-1
kjots                     (>= 4:4.4.3-1) | 4:4.4.3-1
kleopatra                 (>= 4:4.4.3-1) | 4:4.4.3-1
blogilo                   (>= 4:4.4.3-1) | 4:4.4.3-1
akonadiconsole            (>= 4:4.4.3-1) | 4:4.4.3-1


Package's Recommends field is empty.

Package's Suggests field is empty.



Description: Correctly calculate the difference between two years
Origin: backported, http://websvn.kde.org/?view=revision&revision=1128985

---
diff --git a/korganizer/kohelper.cpp b/korganizer/kohelper.cpp
index 4f9dd103166536892de87a4ffbf87e0414124e10..e7a2e9091dc45b9185dab7cc8cdf130cd087a1cf 100644
--- a/korganizer/kohelper.cpp
+++ b/korganizer/kohelper.cpp
@@ -67,8 +67,8 @@ QColor KOHelper::resourceColor( KCal::Calendar *calendar,
   return resourceColor;
 }
 
-qint64 KOHelper::yearDiff( const QDate &start, const QDate &end )
+int KOHelper::yearDiff( const QDate &start, const QDate &end )
 {
-  return static_cast<qint64>( start.daysTo( end ) / 365.25 );
+  return end.year() - start.year();
 }
 
diff --git a/korganizer/kohelper.h b/korganizer/kohelper.h
index 2b77495137397899b2b1893853c67c2e870b3d50..fddc4d04f6534f3e28b67d7267da91d177e3b2a9 100644
--- a/korganizer/kohelper.h
+++ b/korganizer/kohelper.h
@@ -57,7 +57,7 @@ namespace KOHelper
   /**
     Returns the number of years between the @p start QDate and the @p end QDate
   */
-  KORGANIZER_CORE_EXPORT qint64 yearDiff( const QDate &start, const QDate &end );
+  KORGANIZER_CORE_EXPORT int yearDiff( const QDate &start, const QDate &end );
 }
 
 #endif
diff --git a/korganizer/views/agendaview/koagendaitem.cpp b/korganizer/views/agendaview/koagendaitem.cpp
index 9a42a4acb8f746e24bf14089cd36c3a0d06807f4..48480848f7a440926a83cad91802c1f767222371 100644
--- a/korganizer/views/agendaview/koagendaitem.cpp
+++ b/korganizer/views/agendaview/koagendaitem.cpp
@@ -76,7 +76,7 @@ KOAgendaItem::KOAgendaItem( Calendar *calendar, Incidence *incidence,
 
   if ( mIncidence->customProperty( "KABC", "BIRTHDAY" ) == "YES" ||
        mIncidence->customProperty( "KABC", "ANNIVERSARY" ) == "YES" ) {
-    qint64 years = KOHelper::yearDiff( mIncidence->dtStart().date(), qd );
+    int years = KOHelper::yearDiff( mIncidence->dtStart().date(), qd );
     if ( years > 0 ) {
       mIncidence = incidence->clone();
       mIncidence->setReadOnly( false );
diff --git a/korganizer/views/listview/kolistview.cpp b/korganizer/views/listview/kolistview.cpp
index 13a291c2a82f3d76683902dcf0b66003393283de..7b171ad08db2f3efcde4673ad89dbe2c1248d1c6 100644
--- a/korganizer/views/listview/kolistview.cpp
+++ b/korganizer/views/listview/kolistview.cpp
@@ -380,7 +380,7 @@ void KOListView::addIncidence( Incidence *incidence, const QDate &date )
   Incidence *tinc = incidence;
   if ( tinc->customProperty( "KABC", "BIRTHDAY" ) == "YES" ||
        tinc->customProperty( "KABC", "ANNIVERSARY" ) == "YES" ) {
-    qint64 years = KOHelper::yearDiff( tinc->dtStart().date(), mEndDate );
+    int years = KOHelper::yearDiff( tinc->dtStart().date(), mEndDate );
     if ( years > 0 ) {
       tinc = incidence->clone();
       tinc->setReadOnly( false );
diff --git a/korganizer/views/monthview/monthitem.cpp b/korganizer/views/monthview/monthitem.cpp
index 24b0fa5ac4e0d984f03f072d6b4858cab3f792d1..09bae8dc1f21ad5d4409c894fd43ae1e840ef70b 100644
--- a/korganizer/views/monthview/monthitem.cpp
+++ b/korganizer/views/monthview/monthitem.cpp
@@ -286,7 +286,7 @@ IncidenceMonthItem::IncidenceMonthItem( MonthScene *monthScene,
 
   if ( mIncidence->customProperty( "KABC", "BIRTHDAY" ) == "YES" ||
        mIncidence->customProperty( "KABC", "ANNIVERSARY" ) == "YES" ) {
-    qint64 years = KOHelper::yearDiff( mIncidence->dtStart().date(), recurStartDate );
+    int years = KOHelper::yearDiff( mIncidence->dtStart().date(), recurStartDate );
     if ( years > 0 ) {
       mIncidence = incidence->clone();
       mIncidence->setReadOnly( false );

Reply to: