Summary: | calculating leap year birthdays | ||
---|---|---|---|
Product: | [Applications] kontact | Reporter: | Michael Brennan Sayer <michaelb> |
Component: | summary | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 0.1 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | screenshot |
Description
Michael Brennan Sayer
2004-01-16 13:53:13 UTC
Created attachment 4193 [details]
screenshot
Subject: kdepim/kontact/plugins/kaddressbook CVS commit by tokoe: Calculate the correct date for birthdays on XXXX-02-29 in leap years. That fixes #72756. CCMAIL:72756-done@bugs.kde.org M +12 -2 kabsummarywidget.cpp 1.29 --- kdepim/kontact/plugins/kaddressbook/kabsummarywidget.cpp #1.28:1.29 @@ -260,7 +260,17 @@ bool KABSummaryWidget::eventFilter( QObj void KABSummaryWidget::dateDiff( const QDate &date, int &days, int &years ) { - QDate currentDate( 0, QDate::currentDate().month(), QDate::currentDate().day() ); + QDate currentDate; + QDate eventDate; - QDate eventDate( 0, date.month(), date.day() ); + if ( QDate::leapYear( date.year() ) && date.month() == 2 && date.day() == 29 ) { + currentDate = QDate( date.year(), QDate::currentDate().month(), QDate::currentDate().day() ); + if ( !QDate::leapYear( QDate::currentDate().year() ) ) + eventDate = QDate( date.year(), date.month(), 28 ); // celebrate one day earlier ;) + else + eventDate = QDate( date.year(), date.month(), date.day() ); + } else { + currentDate = QDate( 0, QDate::currentDate().month(), QDate::currentDate().day() ); + eventDate = QDate( 0, date.month(), date.day() ); + } int offset = currentDate.daysTo( eventDate ); |