Bug 298756

Summary: KAB calculates wrong age
Product: [Applications] kaddressbook Reporter: Michael Skiba <opensource>
Component: generalAssignee: Allen Winter <winter>
Status: RESOLVED FIXED    
Severity: normal CC: nalvarez, qqqqqqqqq9, tokoe, winter
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 4.9.3

Description Michael Skiba 2012-04-24 17:17:44 UTC
I got two (test) entries in my addressbook:
First person: Birthday on 15.05.1990 (age 21)
Second person: Birthday on 29.04.1991 (age 21)

But that's definitely wrong, but I don't know why it does that. Does KAB calculate birthdays on a month-year basis? That's not a cool solution for an PIM application if you ask me (after all there's about a 1:24 chance that it displays the wrong age)

Reproducible: Always

Steps to Reproduce:
1. Add two new entries
2. Select the dates given above as date of birth
3. Check the age displayed in the "preview" Panel
Actual Results:  
First person: Birthday on 15.05.1990 (age 21)
Second person: Birthday on 29.04.1991 (age 21)

Expected Results:  
First person: Birthday on 15.05.1990 (age 21)
Second person: Birthday on 29.04.1991 (age 20)

Version 4.8.2
Comment 1 qqqqqqqqq9 2012-10-01 18:50:51 UTC
Hi, today on Octobre 1st 2012 kaddressbook report the following Birthday/age combinations: (Jahre = Years)
23. November 1795  (217 Jahre alt)  vs 24. November 1795  (216 Jahre alt) 
 29. Oktober 1900  (112 Jahre alt) vs Dienstag, 30. Oktober 1900  (111 Jahre alt)
Samstag, 22. November 1800  (212 Jahre alt) vs  23. November 1800  (211 Jahre alt)

Possible Reason (Speculation by PovAddict ob #kontact)
kaddressbook  seems to be assuming there are 365 days in a year i. e. ignores leap days.
e. g. (today - 1795/11/23) = 79205, which is an exact multiple of 365
or: (today - 1800/11/22) = 77380 days, which is an exact multiple of 365
Comment 2 qqqqqqqqq9 2012-10-01 18:52:37 UTC
Hi, i should add: 
Archlinux Packages; kontact 4.9.1
Comment 3 Allen Winter 2012-10-01 19:19:27 UTC
I see the problem in grantleecontactformatter.cpp:

 const int years = ( birthday.daysTo( QDate::currentDate() ) / 365 );

will replace that with the dateDiff function found in the sdsummarywidget
Comment 4 Allen Winter 2012-10-03 20:53:42 UTC
Git commit 95c143d27decbf01f6807de9e1e1d588702b2acb by Allen Winter.
Committed on 03/10/2012 at 22:52.
Pushed by winterz into branch 'KDE/4.9'.

fix age computation for birthday strings
FIXED-IN: 4.9.3

M  +11   -1    akonadi/contact/standardcontactformatter.cpp

http://commits.kde.org/kdepimlibs/95c143d27decbf01f6807de9e1e1d588702b2acb
Comment 5 Allen Winter 2012-10-03 21:21:25 UTC
Git commit 43bf2e8551d2a656722acfd0737fec241fbc2f77 by Allen Winter.
Committed on 03/10/2012 at 23:20.
Pushed by winterz into branch 'KDE/4.9'.

fix birthday age computation here too

M  +11   -1    kaddressbook/grantleecontactformatter.cpp

http://commits.kde.org/kdepim/43bf2e8551d2a656722acfd0737fec241fbc2f77