[Korganizer-devel] [Bug 227666] wrong age calculation for birth year 1961 in 2010, 2011 and 2012

Luis Silva lacsilva at gmail.com
Tue Apr 27 18:33:08 CEST 2010


https://bugs.kde.org/show_bug.cgi?id=227666





--- Comment #12 from Luis Silva <lacsilva gmail com>  2010-04-27 18:29:27 ---
(In reply to comment #2)
> The problem lies in the following code:
> 
> qint64 KOHelper::yearDiff( const QDate &start, const QDate &end )
> {
>   return static_cast<qint64>( start.daysTo( end ) / 365.25 );
> }

The correct code should actually be:
qint64 KOHelper::yearDiff( const QDate &start, const QDate &end )
{
  return static_cast<qint64>( (start.daysTo( end ) + 1) / 365.25 );
}

This is a common mistake when doing time/date related maths.

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Korganizer-devel mailing list